diff --git a/Effects/water-inland.eff b/Effects/water-inland.eff index 8d5307988..fa49487f7 100644 --- a/Effects/water-inland.eff +++ b/Effects/water-inland.eff @@ -508,6 +508,11 @@ sea_b + + ocean_flag + int + 0 + @@ -870,6 +875,11 @@ sea_b + + ocean_flag + int + 0 + diff --git a/Effects/water.eff b/Effects/water.eff index bf201aa17..0d3b5d412 100644 --- a/Effects/water.eff +++ b/Effects/water.eff @@ -562,6 +562,11 @@ int quality_level + + ocean_flag + int + 1 + @@ -925,6 +930,11 @@ sea_b + + ocean_flag + int + 1 + diff --git a/Shaders/water_lightfield.frag b/Shaders/water_lightfield.frag index 716169be6..9eb8eb5c0 100644 --- a/Shaders/water_lightfield.frag +++ b/Shaders/water_lightfield.frag @@ -30,6 +30,7 @@ varying vec3 rawPos; varying float earthShade; varying float yprime_alt; varying float mie_angle; +varying float steepness; uniform float WaveFreq ; uniform float WaveAmp ; @@ -57,6 +58,7 @@ uniform float sea_g; uniform float sea_b; uniform int quality_level; +uniform int ocean_flag; vec3 specular_light; @@ -525,11 +527,18 @@ void main(void) float waveSlope = N.g; - - if (windEffect >= 8.0) - if (waveSlope >= foamSlope){ - finalColor = mix(finalColor, max(finalColor, finalColor + foam_texel), smoothstep(0.01, 0.50, N.g)); + float surfFact = 0.0; + if ((windEffect >= 8.0) || (steepness < 0.999)) + { + if ((waveSlope > 0.0) && (ocean_flag ==1)) + { + surfFact = surfFact +(1.0 -smoothstep(0.97,1.0,steepness)); + waveSlope = waveSlope + 2.0 * surfFact; } + if (waveSlope >= foamSlope){ + finalColor = mix(finalColor, max(finalColor, finalColor + foam_texel), smoothstep(0.01, 0.50, N.g+0.2 * surfFact)); + } + } } diff --git a/Shaders/water_lightfield.vert b/Shaders/water_lightfield.vert index f3657a22b..1c014d943 100644 --- a/Shaders/water_lightfield.vert +++ b/Shaders/water_lightfield.vert @@ -15,6 +15,7 @@ varying vec3 rawPos; varying vec3 viewerdir; varying vec3 lightdir; +varying float steepness; varying float earthShade; @@ -31,6 +32,8 @@ uniform float visibility; uniform float overcast; uniform float ground_scattering; +uniform int ocean_flag; + uniform mat4 osg_ViewMatrixInverse; vec3 specular_light; @@ -79,6 +82,11 @@ void main(void) viewerdir = vec3(gl_ModelViewMatrixInverse[3]) - vec3(gl_Vertex); lightdir = normalize(vec3(gl_ModelViewMatrixInverse * gl_LightSource[0].position)); + if (ocean_flag == 1) + {steepness = dot(normalize(gl_Normal), vec3 (0.0, 0.0, 1.0));} + else + {steepness = 0.0;} + waterTex4 = vec4( ecPosition.xzy, 0.0 );