uniform sampler2D uTexMain;
uniform sampler2D uTexDudv;
+uniform sampler2D uTexDepth;
uniform vec2 uInvRes;
uniform float uTime;
-in vec2 aUv;
+in vec4 aUv;
+in vec3 aCo;
void main()
{
vec2 ssuv = gl_FragCoord.xy*uInvRes;
- vec4 dudva = texture( uTexDudv, aUv + vec2(uTime*0.04f,uTime*0.03f) );
- vec4 dudvb = texture( uTexDudv, aUv - vec2(uTime*0.1,uTime*0.054) );
+ vec4 dudva = texture( uTexDudv, aUv.xy + vec2(uTime*0.04f,uTime*0.03f) );
+ vec4 dudvb = texture( uTexDudv, aUv.xy - vec2(uTime*0.1,uTime*0.054) );
vec2 distortamt = (dudva.rg-0.5) * (dudvb.ba-0.5) * 2.0;
vec4 reflected = texture( uTexMain, ssuv+distortamt );
- FragColor = vec4(reflected.rgb*0.9,reflected.a);
+ float depthvalue = texture( uTexDepth, aUv.zw ).r;
+ float opacity = smoothstep( 0.0, 0.1, depthvalue );
+
+ vec3 colour_shore = vec3( 0.96, 0.98, 0.9 );
+ vec3 colour_ocean = vec3( 0.61, 0.84, 0.9 );
+ vec3 surface_tint = mix( colour_shore, colour_ocean, depthvalue );
+
+ vec3 comp_surf = mix(pow(surface_tint,vec3(6.0))*0.6,reflected.rgb, 0.7);
+
+ float band = fract( aCo.z*0.1+uTime*0.1-depthvalue*10.0 );
+ band = step( band + dudvb.g*0.8, 0.5 ) * max((1.0-depthvalue*4.0),0.0);
+
+ FragColor = vec4(comp_surf + band*0.2,opacity+band*0.2);
}