1
0
Fork 0

ALS maintenance: proper order of argument in smoothstep, night behaviour of wake, streamlining of if() statements,...

This commit is contained in:
Thorsten Renk 2014-12-02 11:18:02 +02:00
parent 47aca39183
commit dc791861d2
17 changed files with 38 additions and 95 deletions

View file

@ -379,9 +379,9 @@
<program>
<!-- <vertex-shader>Shaders/include_fog.vert</vertex-shader> -->
<vertex-shader>Shaders/wake_lightfield.vert</vertex-shader>
<vertex-shader>Shaders/wake-ALS.vert</vertex-shader>
<!--<fragment-shader>Shaders/include_fog.frag</fragment-shader>-->
<fragment-shader>Shaders/bowwave_lightfield.frag</fragment-shader>
<fragment-shader>Shaders/bowwave-ALS.frag</fragment-shader>
</program>
<uniform>
<name>water_reflection</name>

View file

@ -463,14 +463,21 @@ if ((dist < 5000.0)&& (quality_level > 3) && (combined_wetness>0.0))
float outscatter = 1.0-exp(-dist/rayleigh_length);
fragColor.rgb = rayleigh_out_shift(fragColor.rgb,outscatter);
// Rayleigh color shift due to in-scattering
float rShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt-340000.0);
float lightIntensity = length(diffuse_term.rgb)/1.73 * rShade;
vec3 rayleighColor = vec3 (0.17, 0.52, 0.87) * lightIntensity;
float rayleighStrength = rayleigh_in_func(dist, air_pollution, avisibility/max(lightIntensity,0.05), eye_alt, eye_alt + relPos.z);
fragColor.rgb = mix(fragColor.rgb, rayleighColor,rayleighStrength);
// here comes the terrain haze model
float delta_z = hazeLayerAltitude - eye_alt;
if (dist > 0.04 * min(visibility,avisibility))
//if ((gl_FragCoord.y > ylimit) || (gl_FragCoord.x < zlimit1) || (gl_FragCoord.x > zlimit2))
//if (dist > 40.0)
{
alt = eye_alt;
@ -597,7 +604,7 @@ hazeColor.r = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0);
// now dim the light for haze
eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1;
eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
// Mie-like factor
@ -638,36 +645,12 @@ if (intensity > 0.0) // this needs to be a condition, because otherwise hazeColo
}
// blue Rayleigh scattering with distance
float rShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt-340000.0) + 0.1;
float lightIntensity = length(diffuse_term.rgb)/1.73 * rShade;
vec3 rayleighColor = vec3 (0.17, 0.52, 0.87) * lightIntensity;
float rayleighStrength = rayleigh_in_func(dist, air_pollution, avisibility/max(lightIntensity,0.05), eye_alt, eye_alt + relPos.z);
fragColor.rgb = mix(fragColor.rgb, rayleighColor,rayleighStrength);
fragColor.rgb = mix((eqColorFactor * hazeColor * eShade) +secondary_light * fog_backscatter(avisibility), fragColor.rgb,transmission);
gl_FragColor = fragColor;
}
else // if dist < threshold no fogging at all
{
// blue Rayleigh scattering with distance
float rShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt-340000.0) + 0.1;
float lightIntensity = length(diffuse_term.rgb)/1.73 * rShade;
vec3 rayleighColor = vec3 (0.17, 0.52, 0.87) * lightIntensity;
float rayleighStrength = rayleigh_in_func(dist, air_pollution, avisibility/max(lightIntensity,0.05), eye_alt, eye_alt + relPos.z);
fragColor.rgb = mix(fragColor.rgb, rayleighColor,rayleighStrength);
gl_FragColor = fragColor;
}
}

View file

@ -435,7 +435,7 @@ hazeColor.r = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0);
// now dim the light for haze
eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1;
eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
// Mie-like factor

View file

@ -287,14 +287,6 @@ void main(void)
finalColor = refl + specular * smoothstep(0.3, 0.6, ground_scattering);
// cover = 0;
/*if(cover >= 1.5){
finalColor = refl + specular;
} else {
finalColor = refl;
}*/
//add foam
float foamSlope = 0.05 + 0.01 * windScale;
@ -309,7 +301,7 @@ void main(void)
}
//generate final colour
finalColor *= ambient_light+ alpha0 * 0.35;
finalColor *= ambient_light;//+ alpha0 * 0.35;
@ -420,7 +412,8 @@ hazeColor.g = light_func(lightArg, 3.931e-06, 0.264, 3.827, 7.93e-06, 1.0);
hazeColor.r = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0);
// now dim the light for haze
float eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1;
float eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
// Mie-like factor

View file

@ -399,7 +399,7 @@ hazeColor.r = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0);
// now dim the light for haze
eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1;
eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
// Mie-like factor

View file

@ -93,9 +93,7 @@ void main()
float effective_scattering = min(scattering, cloud_self_shading);
eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1;
eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
vec4 light_specular = gl_LightSource[0].specular * (eShade - 0.1);
// If gl_Color.a == 0, this is a back-facing polygon and the

View file

@ -601,7 +601,7 @@ hazeColor.r = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0);
// now dim the light for haze
eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1;
eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
// Mie-like factor

View file

@ -224,8 +224,7 @@ if ((dist < 5000.0)&& (quality_level > 3) && (wetness>0.0))
// light computations
eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1;
eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
vec4 light_specular = gl_LightSource[0].specular * eShade;
// If gl_Color.a == 0, this is a back-facing polygon and the

View file

@ -17,12 +17,10 @@ varying float mie_angle;
uniform float visibility;
uniform float avisibility;
uniform float scattering;
//uniform float ground_scattering;
uniform float terminator;
uniform float terrain_alt;
uniform float hazeLayerAltitude;
uniform float overcast;
//uniform float altitude;
uniform float eye_alt;
uniform float cloud_self_shading;
@ -226,8 +224,7 @@ hazeColor.r = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0);
// now dim the light for haze
eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1;
eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
// Mie-like factor

View file

@ -476,7 +476,8 @@ hazeColor.r = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0);
// now dim the light for haze
eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1;
eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
// Mie-like factor

View file

@ -598,7 +598,7 @@ hazeColor.r = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0);
// now dim the light for haze
eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1;
eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
// Mie-like factor

View file

@ -314,7 +314,7 @@ hazeColor.r = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0);
// now dim the light for haze
float eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1;
float eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
// Mie-like factor

View file

@ -348,6 +348,14 @@ if (quality_level > 2)
float outscatter = 1.0-exp(-dist/rayleigh_length);
finalColor.rgb = rayleigh_out_shift(finalColor.rgb,outscatter);
// Rayleigh color shift due to in-scattering
float rShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt-340000.0);
float lightIntensity = length(light_diffuse.rgb)/1.73 * rShade;
vec3 rayleighColor = vec3 (0.17, 0.52, 0.87) * lightIntensity;
float rayleighStrength = rayleigh_in_func(dist, air_pollution, avisibility/max(lightIntensity,0.05), eye_alt, eye_alt + relPos.z);
finalColor.rgb = mix(finalColor.rgb, rayleighColor,rayleighStrength);
// here comes the terrain haze model
@ -468,7 +476,7 @@ hazeColor.r = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0);
// now dim the light for haze
eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1;
eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
// Mie-like factor
@ -517,35 +525,14 @@ if (intensity > 0.0) // this needs to be a condition, because otherwise hazeColo
}
// blue Rayleigh scattering with distance
float rShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt-340000.0) + 0.1;
float lightIntensity = length(light_diffuse.rgb)/1.73 * rShade;
vec3 rayleighColor = vec3 (0.17, 0.52, 0.87) * lightIntensity;
float rayleighStrength = rayleigh_in_func(dist, air_pollution, avisibility/max(lightIntensity,0.05), eye_alt, eye_alt + relPos.z);
finalColor.rgb = mix(finalColor.rgb, rayleighColor,rayleighStrength);
finalColor.rgb = mix((eqColorFactor * hazeColor * eShade) +secondary_light * fog_backscatter(avisibility), finalColor.rgb,transmission);
gl_FragColor = finalColor;
}
else // if dist < threshold no fogging at all
{
// blue Rayleigh scattering with distance
float rShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt-340000.0) + 0.1;
float lightIntensity = length(light_diffuse.rgb)/1.73 * rShade;
vec3 rayleighColor = vec3 (0.17, 0.52, 0.87) * lightIntensity;
float rayleighStrength = rayleigh_in_func(dist, air_pollution, avisibility/max(lightIntensity,0.05), eye_alt, eye_alt + relPos.z);
finalColor.rgb = mix(finalColor.rgb, rayleighColor,rayleighStrength);
gl_FragColor = finalColor;
}
// gl_FragColor = finalColor;
if (dot(normal,-V) > 0.1) {
vec4 iproj = gl_ProjectionMatrix * p;

View file

@ -143,16 +143,6 @@ void main()
// early culling of vertices which can't be seen due to ground haze despite being in aloft visibility range
float delta_z = hazeLayerAltitude - eye_alt;
//if (((dist * (relPos.z - delta_z)/relPos.z > visibility ) && (relPos.z < 0.0) && (delta_z < 0.0) && (dist > 30000.0)))
if (0==1)
{
gl_Position = vec4(0.0, 0.0, -1000.0, 1.0); // move outside of view frustrum, gets culled before reaching fragment shader
earthShade = 1.0;
mie_angle = 1.0;
yprime_alt = 0.0;
}
else
{
// branch dependent on daytime
@ -284,11 +274,6 @@ float shade_depth = 1.0 * smoothstep (0.6,0.95,ground_scattering) * (1.0-smooth
constantColor = gl_FrontMaterial.emission
+ gl_Color * (gl_LightModel.ambient + light_ambient);
}
}

View file

@ -549,7 +549,7 @@ hazeColor.g = light_func(lightArg, 3.931e-06, 0.264, 3.827, 7.93e-06, 1.0);
hazeColor.r = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0);
// now dim the light for haze
float eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1;
float eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
// Mie-like factor

View file

@ -535,7 +535,7 @@ void main(void)
// Rayleigh color shift due to in-scattering
float rShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt-340000.0) + 0.1;
float rShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt-340000.0);
float lightIntensity = length(gl_Color.rgb)/1.73 * rShade;
vec3 rayleighColor = vec3 (0.17, 0.52, 0.87) * lightIntensity;
float rayleighStrength = rayleigh_in_func(dist, air_pollution, avisibility/max(lightIntensity,0.05), eye_alt, eye_alt + relPos.z);
@ -653,7 +653,7 @@ hazeColor.g = light_func(lightArg, 3.931e-06, 0.264, 3.827, 7.93e-06, 1.0);
hazeColor.r = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0);
// now dim the light for haze
float eShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1;
float eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
// Mie-like factor