diff options
Diffstat (limited to 'assets/shaders')
-rw-r--r-- | assets/shaders/Water2.frag.glsl | 30 |
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; | |||
8 | const float PI = 3.1415926535897932; | 8 | const float PI = 3.1415926535897932; |
9 | 9 | ||
10 | //speed | 10 | //speed |
11 | const float speed = 0.2; | 11 | //const float speed = 0.2; |
12 | const float speed_x = 0.3; | 12 | const float speed_x = 0.3; |
13 | const float speed_y = 0.3; | 13 | const float speed_y = 0.3; |
14 | 14 | ||
15 | // geometry | 15 | // geometry |
16 | const float intensity = 3.; | 16 | //const float intensity = 3.; |
17 | const int steps = 8; | 17 | const int steps = 8; |
18 | const float frequency = 4.0; | 18 | const float frequency = 4.0; |
19 | const int angle = 7; // better when a prime | 19 | const int angle = 7; // better when a prime |
20 | 20 | ||
21 | // reflection and emboss | 21 | // reflection and emboss |
22 | const float delta = 20.; | 22 | //const float delta = 20.; |
23 | const float intence = 400.; | 23 | const float intence = 400.; |
24 | const float emboss = 0.3; | 24 | //const float emboss = 0.3; |
25 | |||
26 | // uniforms | ||
27 | uniform float u_emboss; | ||
28 | uniform float u_delta; | ||
29 | //uniform float u_intence; | ||
30 | uniform float u_intensity; | ||
31 | uniform 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) | |||
49 | vec2 p = (gl_FragCoord.xy) / u_resolution.xy, c1 = p, c2 = p; | 56 | vec2 p = (gl_FragCoord.xy) / u_resolution.xy, c1 = p, c2 = p; |
50 | float cc1 = col(c1); | 57 | float cc1 = col(c1); |
51 | 58 | ||
52 | c2.x += u_resolution.x/delta; | 59 | c2.x += u_resolution.x/u_delta; |
53 | float dx = emboss*(cc1-col(c2))/delta; | 60 | float dx = u_emboss*(cc1-col(c2))/u_delta; |
54 | 61 | ||
55 | c2.x = p.x; | 62 | c2.x = p.x; |
56 | c2.y += u_resolution.y/delta; | 63 | c2.y += u_resolution.y/u_delta; |
57 | float dy = emboss*(cc1-col(c2))/delta; | 64 | float dy = u_emboss*(cc1-col(c2))/u_delta; |
58 | 65 | ||
59 | c1.x += dx; | 66 | c1.x += dx; |
60 | c1.y = -(c1.y+dy); | 67 | c1.y = -(c1.y+dy); |
61 | 68 | ||
62 | float alpha = 1.+dot(dx,dy)*intence; | 69 | float alpha = 1.+dot(dx,dy)*intence; |
63 | gl_FragColor = texture2D(u_tex0,c1)*(alpha); | 70 | gl_FragColor = texture2D(u_tex0,c1)*(alpha); |
64 | // gl_FragColor = vec4(col(p),0,0,1); | ||
65 | 71 | ||
66 | } | 72 | } |