aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders/Water2.frag.glsl
diff options
context:
space:
mode:
authorEric Guzman2012-02-27 11:13:35 -0800
committerEric Guzman2012-02-27 11:13:35 -0800
commit1a6604a50f6cfbbf0cd6f45ab94b63a001d02162 (patch)
treebbfc75d1be1ff98d22042dbbed4ca93b4a845e0c /assets/shaders/Water2.frag.glsl
parent9e8cd4448a6d0f809a55c3bdea8b45ed75339794 (diff)
parent8125c8c6c9431067840d81c46624b6a2dd5eb4a7 (diff)
downloadninja-1a6604a50f6cfbbf0cd6f45ab94b63a001d02162.tar.gz
Merge branch 'refs/heads/master' into CSSPanelUpdates
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}