diff options
author | Eric Guzman | 2012-02-27 11:13:35 -0800 |
---|---|---|
committer | Eric Guzman | 2012-02-27 11:13:35 -0800 |
commit | 1a6604a50f6cfbbf0cd6f45ab94b63a001d02162 (patch) | |
tree | bbfc75d1be1ff98d22042dbbed4ca93b4a845e0c /assets/shaders/Water.frag.glsl | |
parent | 9e8cd4448a6d0f809a55c3bdea8b45ed75339794 (diff) | |
parent | 8125c8c6c9431067840d81c46624b6a2dd5eb4a7 (diff) | |
download | ninja-1a6604a50f6cfbbf0cd6f45ab94b63a001d02162.tar.gz |
Merge branch 'refs/heads/master' into CSSPanelUpdates
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 | } | ||