da92d134e8e3bda2c3098b32a88bf3c154190f6e
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / water.fs
1 out vec4 FragColor;
2
3 uniform sampler2D uTexMain;
4 uniform sampler2D uTexDudv;
5 uniform sampler2D uTexDepth;
6 uniform vec2 uInvRes;
7 uniform float uTime;
8
9 in vec4 aUv;
10 in vec3 aCo;
11
12 void main()
13 {
14 vec2 ssuv = gl_FragCoord.xy*uInvRes;
15 vec4 dudva = texture( uTexDudv, aUv.xy + vec2(uTime*0.04f,uTime*0.03f) );
16 vec4 dudvb = texture( uTexDudv, aUv.xy - vec2(uTime*0.1,uTime*0.054) );
17
18 vec2 distortamt = (dudva.rg-0.5) * (dudvb.ba-0.5) * 2.0;
19
20 vec4 reflected = texture( uTexMain, ssuv+distortamt );
21 float depthvalue = texture( uTexDepth, aUv.zw ).r;
22 float opacity = smoothstep( 0.0, 0.1, depthvalue );
23
24 vec3 colour_shore = vec3( 0.96, 0.98, 0.9 );
25 vec3 colour_ocean = vec3( 0.61, 0.84, 0.9 );
26 vec3 surface_tint = mix( colour_shore, colour_ocean, depthvalue );
27
28 vec3 comp_surf = mix(pow(surface_tint,vec3(6.0))*0.6,reflected.rgb, 0.7);
29
30 float band = fract( aCo.z*0.1+uTime*0.1-depthvalue*10.0 );
31 band = step( band + dudvb.g*0.8, 0.5 ) * max((1.0-depthvalue*4.0),0.0);
32
33 FragColor = vec4(comp_surf + band*0.2,opacity+band*0.2);
34 }