- vec4 dudva = texture( uTexDudv, aUv + vec2(uTime*0.04f,uTime*0.03f) );
- vec4 dudvb = texture( uTexDudv, aUv - vec2(uTime*0.1,uTime*0.054) );
+
+ // Surface colour composite
+ float depthvalue = clamp( -world_depth_sample( aCo )*(1.0/25.0), 0.0, 1.0 );
+
+ vec2 world_coord = aCo.xz * 0.008;
+ vec4 time_offsets = vec4( uTime ) * vec4( 0.008, 0.006, 0.003, 0.03 );
+ vec4 dudva = texture( uTexDudv, world_coord + time_offsets.xy )-0.5;
+ vec4 dudvb = texture( uTexDudv, world_coord *7.0 - time_offsets.zw )-0.5;
+
+ vec3 surfnorm = dudva.rgb + dudvb.rgb;
+ surfnorm = normalize(vec3(0.0,1.0,0.0) + dudva.xyz*0.4 + dudvb.xyz*0.1);
+
+ // Foam
+ float fband = fract( aCo.z*0.02+uTime*0.1+depthvalue*10.0 );
+ fband = step( fband+dudva.a*0.8, 0.3 ) * max((1.0-depthvalue*4.0),0.0);
+
+ // Lighting
+ vec3 halfview = -normalize( aCo-uCamera );
+
+ // Sample textures
+ vec4 above = texture( uTexMain, ssuv+ surfnorm.xz*0.2 );
+ vec4 beneath = texture( uTexBack, ssuv );