aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders/Water.frag.glsl
diff options
context:
space:
mode:
authorValerio Virgillito2012-02-23 00:34:37 -0800
committerValerio Virgillito2012-02-23 00:34:37 -0800
commit3675cac3993430490d9eef18157314d53ffa1a6a (patch)
treefb225a6d8fc3c983c96b1507483d628909dc8c1e /assets/shaders/Water.frag.glsl
parent2afef244a3f8124f8a049e504e9782c05904ce23 (diff)
parent3730bbc7cc5d5f07b3d788885475a8f9810b480e (diff)
downloadninja-3675cac3993430490d9eef18157314d53ffa1a6a.tar.gz
Merge pull request #60 from mqg734/WebGLMaterials
Integrating WebGL and canvas-2d drawing fixes. Fixed Materials Editor Popup to work with latest Montage framework. Also adding back WebGL materials.
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}