Shader trick to generate surf at steep coastlines
This commit is contained in:
parent
b3bb82dd88
commit
c937881caf
4 changed files with 41 additions and 4 deletions
|
@ -508,6 +508,11 @@
|
|||
<use>sea_b</use>
|
||||
</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>ocean_flag</name>
|
||||
<type>int</type>
|
||||
<value>0</value>
|
||||
</uniform>
|
||||
<!-- END fog include -->
|
||||
</pass>
|
||||
</technique>
|
||||
|
@ -870,6 +875,11 @@
|
|||
<use>sea_b</use>
|
||||
</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>ocean_flag</name>
|
||||
<type>int</type>
|
||||
<value>0</value>
|
||||
</uniform>
|
||||
<!-- END fog include -->
|
||||
</pass>
|
||||
</technique>
|
||||
|
|
|
@ -562,6 +562,11 @@
|
|||
<type>int</type>
|
||||
<value><use>quality_level</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>ocean_flag</name>
|
||||
<type>int</type>
|
||||
<value>1</value>
|
||||
</uniform>
|
||||
<!-- END fog include -->
|
||||
</pass>
|
||||
</technique>
|
||||
|
@ -925,6 +930,11 @@
|
|||
<use>sea_b</use>
|
||||
</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>ocean_flag</name>
|
||||
<type>int</type>
|
||||
<value>1</value>
|
||||
</uniform>
|
||||
<!-- END fog include -->
|
||||
</pass>
|
||||
</technique>
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
Loading…
Reference in a new issue