diff --git a/Effects/cloud-impostor.eff b/Effects/cloud-impostor.eff index 1225da232..5dc04b36e 100644 --- a/Effects/cloud-impostor.eff +++ b/Effects/cloud-impostor.eff @@ -10,6 +10,7 @@ <cloud_self_shading><use>/environment/cloud-self-shading</use></cloud_self_shading> <moonlight><use>/environment/moonlight</use></moonlight> <air_pollution><use>/environment/air-pollution-norm</use></air_pollution> + <visibility><use>/environment/visibility-m</use></visibility> <use_filtering><use>/sim/rendering/als-filters/use-filtering</use></use_filtering> <gamma><use>/sim/rendering/als-filters/gamma</use></gamma> <brightness><use>/sim/rendering/als-filters/brightness</use></brightness> @@ -103,11 +104,16 @@ <type>float</type> <value><use>moonlight</use></value> </uniform> - <uniform> + <uniform> <name>air_pollution</name> <type>float</type> <value><use>air_pollution</use></value> </uniform> + <uniform> + <name>visibility</name> + <type>float</type> + <value><use>visibility</use></value> + </uniform> <uniform> <name>gamma</name> <type>float</type> diff --git a/Shaders/cloud-impostor-ALS.vert b/Shaders/cloud-impostor-ALS.vert index 67c2b7a41..ae41398ac 100644 --- a/Shaders/cloud-impostor-ALS.vert +++ b/Shaders/cloud-impostor-ALS.vert @@ -10,6 +10,7 @@ uniform float cloud_self_shading; uniform float moonlight; uniform float air_pollution; uniform float range; +uniform float visibility; const float shade = 1.0; const float cloud_height = 1000.0; @@ -85,17 +86,13 @@ void main(void) light_diffuse.r = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0); light_diffuse.a = 1.0; - //float light_intensity = light_func(lightArg, 8.305e-06, 0.161, 3.827, 3.04e-05, 1.0); - //vec4 light_diffuse = vec4 (0.57, 0.57, 0.9, 1.0); - //light_diffuse.rgb = light_intensity * light_diffuse.rgb; // two times terminator width governs how quickly light fades into shadow float terminator_width = 200000.0; float earthShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt) + 0.1; - //float intensity = length(light_diffuse.rgb); float intensity = (1.0 - (0.8 * (1.0 - earthShade))) * length(light_diffuse.rgb); - //light_diffuse.rgb = intensity * normalize(mix(light_diffuse.rgb, shadedFogColor, (1.0 - smoothstep(0.5,0.9, cloud_self_shading )))); + light_diffuse.rgb = intensity * normalize(mix(light_diffuse.rgb, shadedFogColor, (1.0 - smoothstep(0.5,0.9, cloud_self_shading )))); if (earthShade < 0.6) { @@ -103,23 +100,19 @@ void main(void) light_diffuse.rgb = intensity * normalize(mix(light_diffuse.rgb, shadedFogColor, 1.0 -smoothstep(0.1, 0.6,earthShade ) )); } - // Determine the shading of the sprite based on its vertical position and position relative to the sun. - // n = min(smoothstep(-0.5, 0.0, n), fract); -// Determine the shading based on a mixture from the backlight to the front - //vec4 backlight = light_diffuse * shade; - gl_FrontColor = light_diffuse;//mix(backlight, light_diffuse, n); - //gl_FrontColor += gl_FrontLightModelProduct.sceneColor; + + gl_FrontColor = light_diffuse; + // As we get within 100m of the sprite, it is faded out. Equally at large distances it also fades out. gl_FrontColor.a = min(smoothstep(100.0, 250.0, fogCoord), 1.0 - smoothstep(0.9 * range, range, fogCoord)); - // During the day, noctilucent clouds are invisible - //gl_FrontColor.a = gl_FrontColor.a * (1.0 - smoothstep(3.0,5.0,lightArg)); + + gl_FrontColor.a = gl_FrontColor.a * (1.0 - smoothstep(visibility, 3.0* visibility, fogCoord)); + // Fog doesn't affect rain as much as other objects. - //fogFactor = exp( -gl_Fog.density * fogCoord * 0.4); - //fogFactor = clamp(fogFactor, 0.0, 1.0); float fadeScale = 0.05 + 0.2 * log(fogCoord/1000.0); if (fadeScale < 0.05) fadeScale = 0.05; @@ -129,16 +122,9 @@ float fadeScale = 0.05 + 0.2 * log(fogCoord/1000.0); hazeColor.r = hazeColor.r * 0.83; hazeColor.g = hazeColor.g * 0.9; - // in sunset or sunrise conditions, do extra shading of clouds - - - - - //hazeColor = hazeColor * earthShade; - //gl_FrontColor.rgb = gl_FrontColor.rgb * earthShade; gl_FrontColor.rgb = gl_FrontColor.rgb + moonLightColor * (1.0 - smoothstep(0.4, 0.5, earthShade)); hazeColor.rgb = hazeColor.rgb + moonLightColor * (1.0 - smoothstep(0.4, 0.5, earthShade)); gl_BackColor = gl_FrontColor;