aboutsummaryrefslogtreecommitdiff
path: root/assets/shaders/Water2.frag.glsl
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-06-19 15:56:23 -0700
committerNivesh Rajbhandari2012-06-19 15:56:23 -0700
commit3ed06c2a55b1ae840334efeb47f7743944ecb3ca (patch)
tree0ad3e94248a1d4828386c8743a670c709357a470 /assets/shaders/Water2.frag.glsl
parenta0d18963d746e410511c29edd32bc1775d2d5851 (diff)
parent483ad57efcd6475776f580c3af5b60e6deeaf781 (diff)
downloadninja-3ed06c2a55b1ae840334efeb47f7743944ecb3ca.tar.gz
Merge branch 'refs/heads/ninja-internal' into GIO_Fixes
Diffstat (limited to 'assets/shaders/Water2.frag.glsl')
-rw-r--r--assets/shaders/Water2.frag.glsl30
1 files changed, 18 insertions, 12 deletions
diff --git a/assets/shaders/Water2.frag.glsl b/assets/shaders/Water2.frag.glsl
index 39b6aa55..49b2b647 100644
--- a/assets/shaders/Water2.frag.glsl
+++ b/assets/shaders/Water2.frag.glsl
@@ -8,20 +8,27 @@ uniform vec2 u_resolution;
8const float PI = 3.1415926535897932; 8const float PI = 3.1415926535897932;
9 9
10//speed 10//speed
11const float speed = 0.2; 11//const float speed = 0.2;
12const float speed_x = 0.3; 12const float speed_x = 0.3;
13const float speed_y = 0.3; 13const float speed_y = 0.3;
14 14
15// geometry 15// geometry
16const float intensity = 3.; 16//const float intensity = 3.;
17const int steps = 8; 17const int steps = 8;
18const float frequency = 4.0; 18const float frequency = 4.0;
19const int angle = 7; // better when a prime 19const int angle = 7; // better when a prime
20 20
21// reflection and emboss 21// reflection and emboss
22const float delta = 20.; 22//const float delta = 20.;
23const float intence = 400.; 23const float intence = 400.;
24const float emboss = 0.3; 24//const float emboss = 0.3;
25
26// uniforms
27uniform float u_emboss;
28uniform float u_delta;
29//uniform float u_intence;
30uniform float u_intensity;
31uniform float u_speed;
25 32
26//---------- crystals effect 33//---------- crystals effect
27 34
@@ -34,9 +41,9 @@ const float emboss = 0.3;
34 { 41 {
35 vec2 adjc = coord; 42 vec2 adjc = coord;
36 theta = delta_theta*float(i); 43 theta = delta_theta*float(i);
37 adjc.x += cos(theta)*u_time*speed + u_time * speed_x; 44 adjc.x += cos(theta)*u_time*u_speed + u_time * speed_x;
38 adjc.y -= sin(theta)*u_time*speed - u_time * speed_y; 45 adjc.y -= sin(theta)*u_time*u_speed - u_time * speed_y;
39 col = col + cos( (adjc.x*cos(theta) - adjc.y*sin(theta))*frequency)*intensity; 46 col = col + cos( (adjc.x*cos(theta) - adjc.y*sin(theta))*frequency)*u_intensity;
40 } 47 }
41 48
42 return cos(col); 49 return cos(col);
@@ -49,18 +56,17 @@ void main(void)
49vec2 p = (gl_FragCoord.xy) / u_resolution.xy, c1 = p, c2 = p; 56vec2 p = (gl_FragCoord.xy) / u_resolution.xy, c1 = p, c2 = p;
50float cc1 = col(c1); 57float cc1 = col(c1);
51 58
52c2.x += u_resolution.x/delta; 59c2.x += u_resolution.x/u_delta;
53float dx = emboss*(cc1-col(c2))/delta; 60float dx = u_emboss*(cc1-col(c2))/u_delta;
54 61
55c2.x = p.x; 62c2.x = p.x;
56c2.y += u_resolution.y/delta; 63c2.y += u_resolution.y/u_delta;
57float dy = emboss*(cc1-col(c2))/delta; 64float dy = u_emboss*(cc1-col(c2))/u_delta;
58 65
59c1.x += dx; 66c1.x += dx;
60c1.y = -(c1.y+dy); 67c1.y = -(c1.y+dy);
61 68
62float alpha = 1.+dot(dx,dy)*intence; 69float alpha = 1.+dot(dx,dy)*intence;
63gl_FragColor = texture2D(u_tex0,c1)*(alpha); 70gl_FragColor = texture2D(u_tex0,c1)*(alpha);
64// gl_FragColor = vec4(col(p),0,0,1);
65 71
66} 72}