diff options
author | Jose Antonio Marquez | 2012-02-23 10:38:51 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-02-23 10:38:51 -0800 |
commit | d764428023d87446fbbb153d8e04a23b900d71d5 (patch) | |
tree | 2581815db5567b52d4c59663ea9e37d6df057ca3 /assets/shaders/Water.frag.glsl | |
parent | 3e1be6d4d4f0d3a2474af7d915954f9b6464fe2e (diff) | |
parent | cc295dd0fb873505eed01c232bd987cf6e2dcdd9 (diff) | |
download | ninja-d764428023d87446fbbb153d8e04a23b900d71d5.tar.gz |
Merge branch 'refs/heads/NinjaInternal' into Color
Diffstat (limited to 'assets/shaders/Water.frag.glsl')
-rw-r--r-- | assets/shaders/Water.frag.glsl | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/assets/shaders/Water.frag.glsl b/assets/shaders/Water.frag.glsl new file mode 100644 index 00000000..5b71a658 --- /dev/null +++ b/assets/shaders/Water.frag.glsl | |||
@@ -0,0 +1,55 @@ | |||
1 | #ifdef GL_ES | ||
2 | precision highp float; | ||
3 | #endif | ||
4 | |||
5 | uniform sampler2D u_tex0; | ||
6 | uniform float u_time; | ||
7 | uniform vec2 u_resolution; | ||
8 | |||
9 | const float speedx = 1./ 0.1; | ||
10 | const float speedy = 1./ .01; | ||
11 | const float speedr = 1./ 0.01; | ||
12 | const float delta = 20.; | ||
13 | const float intence = 10.; | ||
14 | const int dif = 7; | ||
15 | |||
16 | float col(vec2 coord) | ||
17 | { | ||
18 | float delta_theta = 3.1415926535897932 / float(dif); | ||
19 | float col = 0.; | ||
20 | float theta = 0.; | ||
21 | theta = u_time/200.; | ||
22 | |||
23 | coord.x += u_time/speedx; | ||
24 | coord.y += u_time/speedy; | ||
25 | for (int i = 0; i < dif; i++) | ||
26 | { | ||
27 | coord.x += u_time/speedr; | ||
28 | theta = theta + delta_theta; | ||
29 | col = col + cos( (coord.x*cos(theta) - coord.y*sin(theta))*20. ); | ||
30 | } | ||
31 | |||
32 | return cos(col); | ||
33 | } | ||
34 | |||
35 | void main(void) | ||
36 | { | ||
37 | vec2 p = (gl_FragCoord.xy) / u_resolution.xy; | ||
38 | |||
39 | vec2 c1 = p; | ||
40 | vec2 c2 = p; | ||
41 | |||
42 | c2.x = c2.x+u_resolution.x/delta; | ||
43 | float dx = (col(c1)-col(c2))/delta; | ||
44 | |||
45 | c2 = p; | ||
46 | c2.y = c2.y + u_resolution.y/delta; | ||
47 | float dy = (col(c1)-col(c2))/delta; | ||
48 | |||
49 | c1.x = c1.x+dx; | ||
50 | c1.y = -(c1.y+dy); | ||
51 | |||
52 | float alpha = 1.+dot(dx,dy)*intence; | ||
53 | if (alpha < 0.7) alpha = 0.7; | ||
54 | gl_FragColor = texture2D(u_tex0,c1)*(alpha); | ||
55 | } | ||