aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders/Water.frag.glsl
diff options
context:
space:
mode:
authorAnanya Sen2012-02-23 13:52:32 -0800
committerAnanya Sen2012-02-23 13:52:32 -0800
commitec3d07c2fea4e79c68606234074f43d694982e5b (patch)
treedc7c830c361d35c04a4d9b6d55c6c36d7a5d61cd /assets/shaders/Water.frag.glsl
parent7283884c39df537694b21419a3ea9e3ca7793b4b (diff)
parent287a0bad5b774a380ec6c8b3ddf24dc03234e248 (diff)
downloadninja-ec3d07c2fea4e79c68606234074f43d694982e5b.tar.gz
Merge branch 'refs/heads/FileIO-jose' into FileIO
Conflicts: js/document/html-document.js js/helper-classes/3D/snap-manager.js Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'assets/shaders/Water.frag.glsl')
-rw-r--r--assets/shaders/Water.frag.glsl55
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
2precision highp float;
3#endif
4
5uniform sampler2D u_tex0;
6uniform float u_time;
7uniform vec2 u_resolution;
8
9const float speedx = 1./ 0.1;
10const float speedy = 1./ .01;
11const float speedr = 1./ 0.01;
12const float delta = 20.;
13const float intence = 10.;
14const int dif = 7;
15
16float 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
35void 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}