#include "motion_vectors_fs.glsl"
vec4 water_surf( vec3 halfview, vec3 vnorm, float depthvalue,
- vec4 beneath, vec4 above )
+ vec4 beneath, vec4 above, vec4 dudva )
{
vec3 surface_tint = mix(uShoreColour, uOceanColour, depthvalue);
// Depth
float depthblend = pow( beneath.r, 0.8 );
- // Composite
- vec3 vsurface = mix(surface_tint, above.rgb, ffresnel );
- //vsurface += spec;
+ // 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);
- return vec4( vsurface,depthblend );
+ vec4 surf = mix( vec4(surface_tint,depthblend),
+ vec4(1.0,1.0,1.0,0.5), fband );
+ surf.rgb = scene_compute_lighting( surf.rgb, aNorm.xyz, aWorldCo );
+ surf.rgb = mix(surf.rgb, above.rgb, ffresnel );
+ return surf;
}
void main()
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 );
float fdist = pow(length( aCo.xz-uCamera.xz ) * 0.00047, 2.6);
// Composite
- vec4 vsurface = water_surf( halfview, surfnorm, depthvalue, beneath, above );
+ vec4 vsurface = water_surf( halfview, surfnorm, depthvalue, beneath, above, dudva );
vsurface.a -= fdist;
- oColour = mix( vsurface, vec4(1.0,1.0,1.0,0.5), fband );
- oColour.rgb = scene_compute_lighting( oColour.rgb, aNorm.xyz, aWorldCo );
+
+ oColour = vsurface;
}