From 1e649405d66f17d6acddb9055b181bba7ad70566 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Wed, 16 May 2012 13:41:48 -0700 Subject: Exposing parameters in Water Material --- assets/shaders/Water2.frag.glsl | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'assets') 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; const float PI = 3.1415926535897932; //speed -const float speed = 0.2; +//const float speed = 0.2; const float speed_x = 0.3; const float speed_y = 0.3; // geometry -const float intensity = 3.; +//const float intensity = 3.; const int steps = 8; const float frequency = 4.0; const int angle = 7; // better when a prime // reflection and emboss -const float delta = 20.; +//const float delta = 20.; const float intence = 400.; -const float emboss = 0.3; +//const float emboss = 0.3; + +// uniforms +uniform float u_emboss; +uniform float u_delta; +//uniform float u_intence; +uniform float u_intensity; +uniform float u_speed; //---------- crystals effect @@ -34,9 +41,9 @@ const float emboss = 0.3; { vec2 adjc = coord; theta = delta_theta*float(i); - adjc.x += cos(theta)*u_time*speed + u_time * speed_x; - adjc.y -= sin(theta)*u_time*speed - u_time * speed_y; - col = col + cos( (adjc.x*cos(theta) - adjc.y*sin(theta))*frequency)*intensity; + adjc.x += cos(theta)*u_time*u_speed + u_time * speed_x; + adjc.y -= sin(theta)*u_time*u_speed - u_time * speed_y; + col = col + cos( (adjc.x*cos(theta) - adjc.y*sin(theta))*frequency)*u_intensity; } return cos(col); @@ -49,18 +56,17 @@ void main(void) vec2 p = (gl_FragCoord.xy) / u_resolution.xy, c1 = p, c2 = p; float cc1 = col(c1); -c2.x += u_resolution.x/delta; -float dx = emboss*(cc1-col(c2))/delta; +c2.x += u_resolution.x/u_delta; +float dx = u_emboss*(cc1-col(c2))/u_delta; c2.x = p.x; -c2.y += u_resolution.y/delta; -float dy = emboss*(cc1-col(c2))/delta; +c2.y += u_resolution.y/u_delta; +float dy = u_emboss*(cc1-col(c2))/u_delta; c1.x += dx; c1.y = -(c1.y+dy); float alpha = 1.+dot(dx,dy)*intence; gl_FragColor = texture2D(u_tex0,c1)*(alpha); -// gl_FragColor = vec4(col(p),0,0,1); } -- cgit v1.2.3