1
0
Fork 0

Trees are affected by ALS Rayleigh haze

This commit is contained in:
Thorsten Renk 2014-10-31 13:51:11 +02:00
parent 6376ba1964
commit 1417650438
2 changed files with 22 additions and 4 deletions

View file

@ -32,6 +32,7 @@
<dust_cover_factor><use>/environment/surface/dust-cover-factor</use></dust_cover_factor>
<fogtype><use>/sim/rendering/shaders/skydome</use></fogtype>
<fogstructure><use>/environment/fog-structure</use></fogstructure>
<air_pollution><use>/environment/air-pollution-norm</use></air_pollution>
<cloud_self_shading><use>/environment/cloud-self-shading</use></cloud_self_shading>
<quality_level><use>/sim/rendering/shaders/landmass</use></quality_level>
<tquality_level><use>/sim/rendering/shaders/transition</use></tquality_level>
@ -134,6 +135,7 @@
<vertex-shader>Shaders/cloud-shadowfunc.frag</vertex-shader>
<fragment-shader>Shaders/tree-ALS.frag</fragment-shader>
<fragment-shader>Shaders/secondary_lights.frag</fragment-shader>
<fragment-shader>Shaders/hazes.frag</fragment-shader>
</program>
<uniform>
<name>visibility</name>
@ -549,6 +551,7 @@
<vertex-shader>Shaders/cloud-shadowfunc.frag</vertex-shader>
<fragment-shader>Shaders/tree-ALS.frag</fragment-shader>
<fragment-shader>Shaders/secondary_lights.frag</fragment-shader>
<fragment-shader>Shaders/hazes.frag</fragment-shader>
</program>
<uniform>
<name>visibility</name>

View file

@ -22,6 +22,7 @@ uniform float hazeLayerAltitude;
uniform float overcast;
uniform float eye_alt;
uniform float dust_cover_factor;
uniform float air_pollution;
uniform float landing_light1_offset;
uniform float landing_light2_offset;
@ -41,6 +42,7 @@ float mie_angle;
float light_distance_fading(in float dist);
float fog_backscatter(in float avisibility);
float rayleigh_in_func(in float dist, in float air_pollution, in float avisibility, in float eye_alt, in float vertex_alt);
vec3 searchlight();
vec3 landing_light(in float offset);
@ -66,7 +68,7 @@ return e / pow((1.0 + a * exp(-b * (x-c)) ),(1.0/d));
// physically this should be exp(-arg) but for technical reasons we use a sharper cutoff
// for distance > visibility
float fog_func (in float targ)
float tree_fog_func (in float targ)
{
@ -186,8 +188,6 @@ float delta_z = hazeLayerAltitude - eye_alt;
if (dist > max(40.0, 0.07 * min(visibility,avisibility)))
//if (dist > 40.0)
//if (0==1)
{
alt = eye_alt;
@ -285,7 +285,7 @@ else
transmission = fog_func(transmission_arg);
transmission = tree_fog_func(transmission_arg);
// there's always residual intensity, we should never be driven to zero
if (eqColorFactor < 0.2) eqColorFactor = 0.2;
@ -332,7 +332,14 @@ hazeColor = intensity * normalize(mix(hazeColor, 1.5* shadedFogColor, 1.0 -smoo
hazeColor = intensity * normalize(mix(hazeColor, shadedFogColor, (1.0-smoothstep(0.5,0.9,eqColorFactor))));
// Rayleigh haze
float rShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt-340000.0) + 0.1;
float lightIntensity = length(gl_Color.rgb)/0.72 * 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);
if ((quality_level > 5) && (tquality_level > 5))
{fragColor.rgb = mix(fragColor.rgb, rayleighColor, rayleighStrength);}
// determine the right mix of transmission and haze
@ -344,6 +351,14 @@ gl_FragColor = fragColor;
}
else // if dist < 40.0 no fogging at all
{
float rShade = 0.9 * smoothstep(terminator_width+ terminator, -terminator_width + terminator, yprime_alt-340000.0) + 0.1;
float lightIntensity = length(gl_Color.rgb)/0.72 * 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);
if ((quality_level > 5) && (tquality_level > 5))
{fragColor.rgb = mix(fragColor.rgb, rayleighColor, rayleighStrength);}
gl_FragColor = fragColor;
}