aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders/Water2.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/Water2.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/Water2.frag.glsl')
-rw-r--r--assets/shaders/Water2.frag.glsl66
1 files changed, 66 insertions, 0 deletions
diff --git a/assets/shaders/Water2.frag.glsl b/assets/shaders/Water2.frag.glsl
new file mode 100644
index 00000000..39b6aa55
--- /dev/null
+++ b/assets/shaders/Water2.frag.glsl
@@ -0,0 +1,66 @@
1#ifdef GL_ES
2precision highp float;
3#endif
4
5uniform sampler2D u_tex0;
6uniform float u_time;
7uniform vec2 u_resolution;
8const float PI = 3.1415926535897932;
9
10//speed
11const float speed = 0.2;
12const float speed_x = 0.3;
13const float speed_y = 0.3;
14
15// geometry
16const float intensity = 3.;
17const int steps = 8;
18const float frequency = 4.0;
19const int angle = 7; // better when a prime
20
21// reflection and emboss
22const float delta = 20.;
23const float intence = 400.;
24const float emboss = 0.3;
25
26//---------- crystals effect
27
28 float col(vec2 coord)
29 {
30 float delta_theta = 2.0 * PI / float(angle);
31 float col = 0.0;
32 float theta = 0.0;
33 for (int i = 0; i < steps; i++)
34 {
35 vec2 adjc = coord;
36 theta = delta_theta*float(i);
37 adjc.x += cos(theta)*u_time*speed + u_time * speed_x;
38 adjc.y -= sin(theta)*u_time*speed - u_time * speed_y;
39 col = col + cos( (adjc.x*cos(theta) - adjc.y*sin(theta))*frequency)*intensity;
40 }
41
42 return cos(col);
43 }
44
45//---------- main
46
47void main(void)
48{
49vec2 p = (gl_FragCoord.xy) / u_resolution.xy, c1 = p, c2 = p;
50float cc1 = col(c1);
51
52c2.x += u_resolution.x/delta;
53float dx = emboss*(cc1-col(c2))/delta;
54
55c2.x = p.x;
56c2.y += u_resolution.y/delta;
57float dy = emboss*(cc1-col(c2))/delta;
58
59c1.x += dx;
60c1.y = -(c1.y+dy);
61
62float alpha = 1.+dot(dx,dy)*intence;
63gl_FragColor = texture2D(u_tex0,c1)*(alpha);
64// gl_FragColor = vec4(col(p),0,0,1);
65
66}