1
0
Fork 0

ALS maintenance - reworked light curves, streamlining, minor bugfixes,...

This commit is contained in:
Thorsten Renk 2014-12-15 15:50:47 +02:00
parent 576f72ba53
commit 2c0513816c
35 changed files with 185 additions and 182 deletions

View file

@ -382,6 +382,7 @@
<vertex-shader>Shaders/wake-ALS.vert</vertex-shader>
<!--<fragment-shader>Shaders/include_fog.frag</fragment-shader>-->
<fragment-shader>Shaders/bowwave-ALS.frag</fragment-shader>
<fragment-shader>Shaders/hazes.frag</fragment-shader>
</program>
<uniform>
<name>water_reflection</name>

View file

@ -284,8 +284,9 @@
</internal-format>
</texture-unit>
<program>
<vertex-shader>Shaders/building-haze.vert</vertex-shader>
<vertex-shader>Shaders/building-ALS.vert</vertex-shader>
<fragment-shader>Shaders/terrain-ALS-base.frag</fragment-shader>
<fragment-shader>Shaders/hazes.frag</fragment-shader>
</program>
<uniform>
<name>visibility</name>

View file

@ -56,8 +56,8 @@
<wrap-t>clamp</wrap-t>-->
</texture-unit>
<program>
<vertex-shader>Shaders/cloud-noctilucent-lightfield.vert</vertex-shader>
<fragment-shader>Shaders/cloud-static-lightfield.frag</fragment-shader>
<vertex-shader>Shaders/cloud-noctilucent-ALS.vert</vertex-shader>
<fragment-shader>Shaders/cloud-static-ALS.frag</fragment-shader>
</program>
<uniform>
<name>baseTexture</name>

View file

@ -56,8 +56,8 @@
<wrap-t>clamp</wrap-t>-->
</texture-unit>
<program>
<vertex-shader>Shaders/cloud-static-lightfield.vert</vertex-shader>
<fragment-shader>Shaders/cloud-static-lightfield.frag</fragment-shader>
<vertex-shader>Shaders/cloud-static-ALS.vert</vertex-shader>
<fragment-shader>Shaders/cloud-static-ALS.frag</fragment-shader>
</program>
<uniform>
<name>baseTexture</name>

View file

@ -150,6 +150,7 @@
<vertex-shader>Shaders/flutter-ALS.vert</vertex-shader>
<fragment-shader>Shaders/terrain-ALS-base.frag</fragment-shader>
<fragment-shader>Shaders/hazes.frag</fragment-shader>
</program>
<!--<uniform>
<name>texture</name>

View file

@ -61,7 +61,8 @@ void main(void)
float intensity;
float mix_factor;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);//vec3 (0.55, 0.6, 0.8);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight * scattering;
gl_TexCoord[0] = gl_MultiTexCoord0;
vec4 ep = gl_ModelViewMatrixInverse * vec4(0.0,0.0,0.0,1.0);
@ -159,6 +160,7 @@ 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;
//light_diffuse *= cloud_self_shading;
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, min(scattering, cloud_self_shading) ))));

View file

@ -121,7 +121,7 @@ float ct = dot(vec3(0.0, 0.0, 1.0), relPos)/dist;
float msl_altitude = (relPos.z + eye_alt);
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
// this is taken from default.frag
vec3 n;
float NdotL, NdotHV, fogFactor;
@ -473,7 +473,9 @@ if ((dist < 5000.0)&& (quality_level > 3) && (combined_wetness>0.0))
float delta_z = hazeLayerAltitude - eye_alt;
if (dist > 0.04 * min(visibility,avisibility))
float mvisibility = min(visibility,avisibility);
if (dist > 0.04 * mvisibility)
{
alt = eye_alt;
@ -496,7 +498,7 @@ if (delta_z > 0.0) // we're inside the layer
if (ct < 0.0) // we look down
{
distance_in_layer = dist;
vAltitude = min(distance_in_layer,min(visibility, avisibility)) * ct;
vAltitude = min(distance_in_layer,mvisibility) * ct;
delta_zv = delta_z - vAltitude;
}
else // we may look through upper layer edge
@ -590,7 +592,7 @@ transmission = fog_func(transmission_arg, alt);
if (eqColorFactor < 0.2) eqColorFactor = 0.2;
float lightArg = (terminator-yprime_alt)/100000.0;
//float lightArg = (terminator-yprime_alt)/100000.0;
@ -643,7 +645,7 @@ vec3 minLight = minLightIntensity * vec3 (0.2, 0.3, 0.4);
hazeColor.rgb *= eqColorFactor * eShade;
hazeColor.rgb = max(hazeColor.rgb, minLight.rgb);
fragColor.rgb = mix(hazeColor + secondary_light * fog_backscatter(avisibility), fragColor.rgb,transmission);
fragColor.rgb = mix(hazeColor + secondary_light * fog_backscatter(mvisibility), fragColor.rgb,transmission);
}

View file

@ -5,6 +5,7 @@
varying vec4 diffuse_term;
varying vec3 normal;
varying vec3 relPos;
varying vec3 worldPos;
varying vec2 rawPos;
varying vec3 ecViewdir;
@ -49,6 +50,7 @@ uniform int use_alt_landing_light;
const float EarthRadius = 5800000.0;
const float terminator_width = 200000.0;
float alt;
float eShade;
float yprime_alt;
@ -56,6 +58,7 @@ float mie_angle;
float shadow_func (in float x, in float y, in float noise, in float dist);
float Noise2D(in vec2 coord, in float wavelength);
float Noise3D(in vec3 coord, in float wavelength);
float fog_func (in float targ, in float alt);
float rayleigh_in_func(in float dist, in float air_pollution, in float avisibility, in float eye_alt, in float vertex_alt);
float alt_factor(in float eye_alt, in float vertex_alt);
@ -94,7 +97,7 @@ yprime_alt = diffuse_term.a;
//diffuse_term.a = 1.0;
mie_angle = gl_Color.a;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
float dist = length(relPos);
float ct = dot(vec3(0.0, 0.0, 1.0), relPos)/dist;
@ -134,10 +137,10 @@ float noise_5m = Noise2D(rawPos.xy,5.0);
float noise_50m = Noise2D(rawPos.xy, 500.0);
float noise_1500m = Noise2D(rawPos.xy, 1500.0);
float noise_2000m = Noise2D(rawPos.xy, 2000.0);
float noise_50m = Noise2D(rawPos.xy, 50.0);
float noise_1500m = Noise3D(worldPos.xyz, 1500.0);
float noise_2000m = Noise3D(worldPos.xyz, 2000.0);
@ -327,8 +330,9 @@ if (quality_level > 3)
float delta_z = hazeLayerAltitude - eye_alt;
float mvisibility = min(visibility,avisibility);
if (dist > 0.04 * min(visibility,avisibility))
if (dist > 0.04 * mvisibility)
{
alt = eye_alt;
@ -351,7 +355,7 @@ if (delta_z > 0.0) // we're inside the layer
if (ct < 0.0) // we look down
{
distance_in_layer = dist;
vAltitude = min(distance_in_layer,min(visibility, avisibility)) * ct;
vAltitude = min(distance_in_layer,mvisibility) * ct;
delta_zv = delta_z - vAltitude;
}
else // we may look through upper layer edge
@ -446,6 +450,10 @@ if (lightArg < 10.0)
// high altitude desaturation of the haze color
intensity = length(hazeColor);
if (intensity>0.0)
{
hazeColor = intensity * normalize (mix(hazeColor, intensity * vec3 (1.0,1.0,1.0), 0.7* smoothstep(5000.0, 50000.0, alt)));
// blue hue of haze
@ -459,18 +467,18 @@ float fade_out = max(0.65 - 0.3 *overcast, 0.45);
intensity = length(hazeColor);
hazeColor = intensity * normalize(mix(hazeColor, 1.5* shadedFogColor, 1.0 -smoothstep(0.25, fade_out,eShade) ));
// change haze color to blue hue for strong fogging
hazeColor = intensity * normalize(mix(hazeColor, shadedFogColor, (1.0-smoothstep(0.5,0.9,eqColorFactor))));
// reduce haze intensity when looking at shaded surfaces, only in terminator region
float shadow = mix( min(1.0 + dot(n,lightDir),1.0), 1.0, 1.0-smoothstep(0.1, 0.4, transmission));
hazeColor = mix(shadow * hazeColor, hazeColor, 0.3 + 0.7* smoothstep(250000.0, 400000.0, terminator));
}
hazeColor = clamp(hazeColor,0.0,1.0);
//hazeColor = clamp(hazeColor,0.0,1.0);
// don't let the light fade out too rapidly
lightArg = (terminator + 200000.0)/100000.0;
@ -481,7 +489,7 @@ hazeColor.rgb *= eqColorFactor * eShade;
hazeColor.rgb = max(hazeColor.rgb, minLight.rgb);
fragColor.rgb = mix(hazeColor+secondary_light * fog_backscatter(avisibility), fragColor.rgb,transmission);
fragColor.rgb = mix(hazeColor+secondary_light * fog_backscatter(mvisibility), fragColor.rgb,transmission);

View file

@ -56,14 +56,13 @@ varying float steepness;
vec3 specular_light;
float fog_func (in float targ, in float alt);
vec3 get_hazeColor(in float light_arg);
const float terminator_width = 200000.0;
const float EarthRadius = 5800000.0;
////fog "include" /////
uniform int fogType;
vec3 fog_Func(vec3 color, int type);
//////////////////////
/////// functions /////////
@ -122,32 +121,8 @@ 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 fade_mix;
// for large altitude > 30 km, we switch to some component of quadratic distance fading to
// create the illusion of improved visibility range
targ = 1.25 * targ; // need to sync with the distance to which terrain is drawn
if (eye_alt < 30000.0)
{return exp(-targ - targ * targ * targ * targ);}
else if (eye_alt < 50000.0)
{
fade_mix = (eye_alt - 30000.0)/20000.0;
return fade_mix * exp(-targ*targ - pow(targ,4.0)) + (1.0 - fade_mix) * exp(-targ - pow(targ,4.0));
}
else
{
return exp(- targ * targ - pow(targ,4.0));
}
}
//////////////////////
void main(void)
@ -162,7 +137,7 @@ void main(void)
float relWinddir=0;
float dist = length(relPos);
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
float effective_scattering = min(scattering, cloud_self_shading);
// compute relative wind speed and direction
@ -398,7 +373,7 @@ else
}
transmission = fog_func(transmission_arg);
transmission = fog_func(transmission_arg, eye_alt);
// there's always residual intensity, we should never be driven to zero
if (eqColorFactor < 0.2) eqColorFactor = 0.2;
@ -406,10 +381,8 @@ if (eqColorFactor < 0.2) eqColorFactor = 0.2;
float lightArg = (terminator-yprime_alt)/100000.0;
vec3 hazeColor;
hazeColor.b = light_func(lightArg, 1.330e-05, 0.264, 2.527, 1.08e-05, 1.0);
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);
vec3 hazeColor = get_hazeColor(lightArg);
// now dim the light for haze
float eShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt);
@ -449,14 +422,22 @@ if (intensity > 0.0) // this needs to be a condition, because otherwise hazeColo
finalColor.rgb = mix(eqColorFactor * hazeColor * eShade, finalColor.rgb,transmission);
// don't let the light fade out too rapidly
lightArg = (terminator + 200000.0)/100000.0;
float minLightIntensity = min(0.2,0.16 * lightArg + 0.5);
vec3 minLight = minLightIntensity * vec3 (0.2, 0.3, 0.4);
hazeColor.rgb *= eqColorFactor * eShade;
hazeColor.rgb = max(hazeColor.rgb, minLight.rgb);
finalColor.rgb = mix(hazeColor, finalColor.rgb,transmission);
}
//finalColor.rgb = fog_Func(finalColor.rgb, fogType);
gl_FragColor = vec4(finalColor.rgb, alpha0.a * 1.35);
//gl_FragColor = finalColor;
}

View file

@ -70,7 +70,7 @@ void main()
float intensity;
float vertex_alt;
float scattering;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
// this code is copied from default.vert
@ -173,10 +173,10 @@ if (earthShade < 0.5)
{
//light_ambient = light_ambient * (0.4 + 0.6 * smoothstep(0.2, 0.5, earthShade));
intensity = length(light_ambient.rgb);
light_ambient.rgb = intensity * normalize(mix(light_ambient.rgb, shadedFogColor, 1.0 -smoothstep(0.1, 0.8,earthShade) ));
light_ambient.rgb = intensity * normalize(mix(light_ambient.rgb, shadedFogColor, 1.0 -smoothstep(0.4, 0.8,earthShade) ));
intensity = length(light_diffuse.rgb);
light_diffuse.rgb = intensity * normalize(mix(light_diffuse.rgb, shadedFogColor, 1.0 -smoothstep(0.1, 0.7,earthShade) ));
light_diffuse.rgb = intensity * normalize(mix(light_diffuse.rgb, shadedFogColor, 1.0 -smoothstep(0.4, 0.7,earthShade) ));
}

View file

@ -33,7 +33,7 @@ return e / pow((1.0 + a * exp(-b * (x-c)) ),(1.0/d));
void main(void)
{
vec3 shadedFogColor = vec3 (0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3 (0.55, 0.67, 0.88);
vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;

View file

@ -31,7 +31,7 @@ return e / pow((1.0 + a * exp(-b * (x-c)) ),(1.0/d));
void main(void)
{
vec3 shadedFogColor = vec3 (0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3 (0.55, 0.67, 0.88);
vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;

View file

@ -31,7 +31,7 @@ return e / pow((1.0 + a * exp(-b * (x-c)) ),(1.0/d));
void main(void)
{
vec3 shadedFogColor = vec3 (0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3 (0.55, 0.67, 0.88);
vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;

View file

@ -83,7 +83,7 @@ float dist = length(relPos);
float ct = dot(vec3(0.0, 0.0, 1.0), relPos)/dist;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
// this is taken from default.frag
vec3 n;
float NdotL, NdotHV, fogFactor;
@ -296,10 +296,10 @@ vec3 hazeColor = get_hazeColor(lightArg);
float delta_z = hazeLayerAltitude - eye_alt;
float mvisibility = min(visibility,avisibility);
if (dist > 0.04 * mvisibility)
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;
@ -322,7 +322,7 @@ if (delta_z > 0.0) // we're inside the layer
if (ct < 0.0) // we look down
{
distance_in_layer = dist;
vAltitude = min(distance_in_layer,min(visibility, avisibility)) * ct;
vAltitude = min(distance_in_layer,mvisibility) * ct;
delta_zv = delta_z - vAltitude;
}
else // we may look through upper layer edge
@ -452,7 +452,7 @@ vec3 minLight = minLightIntensity * vec3 (0.2, 0.3, 0.4);
hazeColor.rgb *= eqColorFactor * eShade;
hazeColor.rgb = max(hazeColor.rgb, minLight.rgb);
fragColor.rgb = mix( hazeColor +secondary_light * fog_backscatter(avisibility) , fragColor.rgb,transmission);
fragColor.rgb = mix( hazeColor +secondary_light * fog_backscatter(mvisibility) , fragColor.rgb,transmission);
}

View file

@ -100,7 +100,7 @@ void main()
{
vec4 light_diffuse;
vec4 light_ambient;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight;

View file

@ -59,7 +59,7 @@ void main()
vec4 light_diffuse;
vec4 light_ambient;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight;
@ -164,11 +164,11 @@ if (earthShade < 0.5)
//light_ambient = light_ambient * (0.7 + 0.3 * smoothstep(0.2, 0.5, earthShade));
intensity = length(light_ambient.xyz);
light_ambient.rgb = intensity * normalize(mix(light_ambient.rgb, shadedFogColor, 1.0 -smoothstep(0.1, 0.8,earthShade) ));
light_ambient.rgb = intensity * normalize(mix(light_ambient.rgb, shadedFogColor, 1.0 -smoothstep(0.4, 0.8,earthShade) ));
light_ambient.rgb = light_ambient.rgb + moonLightColor * (1.0 - smoothstep(0.4, 0.5, earthShade));
intensity = length(light_diffuse.xyz);
light_diffuse.rgb = intensity * normalize(mix(light_diffuse.rgb, shadedFogColor, 1.0 -smoothstep(0.1, 0.7,earthShade) ));
light_diffuse.rgb = intensity * normalize(mix(light_diffuse.rgb, shadedFogColor, 1.0 -smoothstep(0.4, 0.7,earthShade) ));
}

View file

@ -81,7 +81,7 @@ return e / pow((1.0 + a * exp(-b * (x-c)) ),(1.0/d));
void main()
{
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
// this is taken from default.frag
vec3 n;
float NdotL, NdotHV, fogFactor;
@ -152,6 +152,9 @@ vec3 hazeColor = get_hazeColor(lightArg);
if ((quality_level > 5) && (tquality_level > 5))
{
float rayleigh_length = 0.5 * avisibility * (2.5 - 1.9 * air_pollution)/alt_factor(eye_alt, eye_alt+relPos.z);
float outscatter = 1.0-exp(-dist/rayleigh_length);
fragColor.rgb = rayleigh_out_shift(fragColor.rgb,outscatter);
float rShade = 1.0 - 0.9 * smoothstep(-terminator_width+ terminator, terminator_width + terminator, yprime_alt + 420000.0);
float lightIntensity = length(hazeColor * effective_scattering) * rShade;
vec3 rayleighColor = vec3 (0.17, 0.52, 0.87) * lightIntensity;
@ -164,9 +167,9 @@ vec3 hazeColor = get_hazeColor(lightArg);
float delta_z = hazeLayerAltitude - eye_alt;
float mvisibility = min(visibility, avisibility);
if (dist > 0.04 * min(visibility,avisibility))
if (dist > 0.04 * mvisibility)
{
alt = eye_alt;
@ -190,7 +193,7 @@ if (delta_z > 0.0) // we're inside the layer
if (ct < 0.0) // we look down
{
distance_in_layer = dist;
vAltitude = min(distance_in_layer,min(visibility, avisibility)) * ct;
vAltitude = min(distance_in_layer,mvisibility) * ct;
delta_zv = delta_z - vAltitude;
}
else // we may look through upper layer edge
@ -303,7 +306,7 @@ hazeColor.rgb = max(hazeColor.rgb, minLight.rgb);
// determine the right mix of transmission and haze
fragColor.rgb = mix(hazeColor + secondary_light * fog_backscatter(avisibility), fragColor.rgb,transmission);
fragColor.rgb = mix(hazeColor + secondary_light * fog_backscatter(mvisibility), fragColor.rgb,transmission);

View file

@ -131,7 +131,7 @@ void main (void)
float pf = 0.0;
float pf1 = 0.0;
///some generic light scattering parameters
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight;
float alt = eye_alt;
float effective_scattering = min(scattering, cloud_self_shading);
@ -430,15 +430,16 @@ void main (void)
float eqColorFactor;
float delta_z = hazeLayerAltitude - eye_alt;
float mvisibility = min(visibility, avisibility);
if (dist > max(40.0, 0.04 * min(visibility,avisibility)))
if (dist > 0.04 * mvisibility)
{
if (delta_z > 0.0) // we're inside the layer
{
if (ct < 0.0) // we look down
{
distance_in_layer = dist;
vAltitude = min(distance_in_layer,min(visibility, avisibility)) * ct;
vAltitude = min(distance_in_layer,mvisibility) * ct;
delta_zv = delta_z - vAltitude;
}
else // we may look through upper layer edge
@ -532,7 +533,7 @@ void main (void)
/// END fog color
fragColor = clamp(fragColor, 0.0, 1.0);
hazeColor = clamp(hazeColor, 0.0, 1.0);
//hazeColor = clamp(hazeColor, 0.0, 1.0);
///BEGIN Rayleigh fog ///
@ -555,6 +556,6 @@ void main (void)
hazeColor.rgb = max(hazeColor.rgb, minLight.rgb);
fragColor.rgb = mix(hazeColor +secondary_light * fog_backscatter(avisibility), fragColor.rgb,transmission);
fragColor.rgb = mix(hazeColor +secondary_light * fog_backscatter(mvisibility), fragColor.rgb,transmission);
gl_FragColor = fragColor;
}

View file

@ -121,7 +121,7 @@ float ct = dot(vec3(0.0, 0.0, 1.0), relPos)/dist;
float msl_altitude = (relPos.z + eye_alt);
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
// this is taken from default.frag
vec3 n;
float NdotL, NdotHV, fogFactor;
@ -501,9 +501,10 @@ vec3 hazeColor = get_hazeColor(lightArg);
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)
float mvisibility = min(visibility,avisibility);
if (dist > 0.04 * mvisibility)
{
alt = eye_alt;
@ -526,7 +527,7 @@ if (delta_z > 0.0) // we're inside the layer
if (ct < 0.0) // we look down
{
distance_in_layer = dist;
vAltitude = min(distance_in_layer,min(visibility, avisibility)) * ct;
vAltitude = min(distance_in_layer,mvisibility) * ct;
delta_zv = delta_z - vAltitude;
}
else // we may look through upper layer edge
@ -659,7 +660,7 @@ hazeColor.rgb *= eqColorFactor * eShade;
hazeColor.rgb = max(hazeColor.rgb, minLight.rgb);
fragColor.rgb = mix(hazeColor, fragColor.rgb,transmission);
fragColor.rgb = mix(hazeColor + secondary_light * fog_backscatter(mvisibility), fragColor.rgb,transmission);
}

View file

@ -6,6 +6,7 @@ varying vec4 diffuse_term;
varying vec3 normal;
varying vec3 relPos;
varying vec2 rawPos;
varying vec3 worldPos;
varying vec3 ecViewdir;
@ -54,6 +55,7 @@ float mie_angle;
float shadow_func (in float x, in float y, in float noise, in float dist);
float Noise2D(in vec2 coord, in float wavelength);
float Noise3D(in vec3 coord, in float wavelength);
float DotNoise2D(in vec2 coord, in float wavelength, in float fractionalMaxDotSize, in float dot_density);
float fog_func (in float targ, in float alt);
float alt_factor(in float eye_alt, in float vertex_alt);
@ -81,7 +83,7 @@ void main()
float ct = dot(vec3(0.0, 0.0, 1.0), relPos)/dist;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
// this is taken from default.frag
vec3 n;
float NdotL, NdotHV;
@ -123,13 +125,12 @@ noise_5m = Noise2D(rawPos.xy ,5.0);
float noisegrad_10m;
float noisegrad_5m;
float noise_50m = Noise2D(rawPos.xy, 50.0);;
float noise_250m;
float noise_500m = Noise2D(rawPos.xy, 500.0);
float noise_1500m = Noise2D(rawPos.xy, 1500.0);
float noise_2000m = Noise2D(rawPos.xy, 2000.0);
float noise_50m = Noise2D(rawPos.xy, 50.0);
float noise_1500m = Noise3D(worldPos.xyz, 1500.0);
float noise_2000m = Noise3D(worldPos.xyz, 2000.0);
@ -308,8 +309,9 @@ float lightArg = (terminator-yprime_alt)/100000.0;
float delta_z = hazeLayerAltitude - eye_alt;
float mvisibility = min(visibility, avisibility);
if (dist > 0.04 * min(visibility,avisibility))
if (dist > 0.04 * mvisibility)
{
alt = eye_alt;
@ -332,7 +334,7 @@ if (delta_z > 0.0) // we're inside the layer
if (ct < 0.0) // we look down
{
distance_in_layer = dist;
vAltitude = min(distance_in_layer,min(visibility, avisibility)) * ct;
vAltitude = min(distance_in_layer,mvisibility) * ct;
delta_zv = delta_z - vAltitude;
}
else // we may look through upper layer edge
@ -449,7 +451,7 @@ if (intensity > 0.0) // this needs to be a condition, because otherwise hazeColo
float shadow = mix( min(1.0 + dot(n,lightDir),1.0), 1.0, 1.0-smoothstep(0.1, 0.4, transmission));
hazeColor = mix(shadow * hazeColor, hazeColor, 0.3 + 0.7* smoothstep(250000.0, 400000.0, terminator));
}
hazeColor = clamp(hazeColor, 0.0, 1.0);
//hazeColor = clamp(hazeColor, 0.0, 1.0);
// don't let the light fade out too rapidly
lightArg = (terminator + 200000.0)/100000.0;
@ -459,7 +461,7 @@ vec3 minLight = minLightIntensity * vec3 (0.2, 0.3, 0.4);
hazeColor.rgb *= eqColorFactor * eShade;
hazeColor.rgb = max(hazeColor.rgb, minLight.rgb);
fragColor.rgb = mix(hazeColor +secondary_light * fog_backscatter(avisibility), fragColor.rgb,transmission);
fragColor.rgb = mix(hazeColor +secondary_light * fog_backscatter(mvisibility), fragColor.rgb,transmission);

View file

@ -72,7 +72,8 @@ float rayleighPhase(in float cosTheta)
void main()
{
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
//vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
float cosTheta = dot(normalize(eye), gl_LightSource[0].position.xyz);
// position of the horizon line

View file

@ -43,7 +43,7 @@ float luminance(vec3 color)
void main()
{
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
// this is taken from default.frag
vec3 n;
float NdotL, NdotHV, fogFactor;
@ -90,7 +90,9 @@ void main()
float delta_z = hazeLayerAltitude - eye_alt;
float dist = length(relPos);
if (dist > 0.04 * min(visibility,avisibility))
float mvisibility = min(visibility,avisibility);
if (dist > 0.04 * mvisibility)
{
alt = eye_alt;
@ -114,7 +116,7 @@ if (delta_z > 0.0) // we're inside the layer
if (ct < 0.0) // we look down
{
distance_in_layer = dist;
vAltitude = min(distance_in_layer,min(visibility, avisibility)) * ct;
vAltitude = min(distance_in_layer,mvisibility) * ct;
delta_zv = delta_z - vAltitude;
}
else // we may look through upper layer edge
@ -153,7 +155,7 @@ transmission_arg = (dist-distance_in_layer)/avisibility;
float eqColorFactor;
//float scattering = ground_scattering + (1.0 - ground_scattering) * smoothstep(hazeLayerAltitude -100.0, hazeLayerAltitude + 100.0, relPos.z + eye_alt);
if (visibility < avisibility)
{
@ -174,7 +176,7 @@ else
transmission = fog_func(transmission_arg, alt);
// there's always residual intensity, we should never be driven to zero
if (eqColorFactor < 0.2) eqColorFactor = 0.2;
if (eqColorFactor < 0.2) {eqColorFactor = 0.2;}
float lightArg = (terminator-yprime_alt)/100000.0;

View file

@ -73,7 +73,7 @@ float dist = length(relPos);
float ct = dot(vec3(0.0, 0.0, 1.0), relPos)/dist;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
// this is taken from default.frag
vec3 n;
float NdotL, NdotHV, fogFactor;
@ -490,19 +490,12 @@ if (intensity > 0.0) // this needs to be a condition, because otherwise hazeColo
fragColor.rgb = mix(hazeColor , fragColor.rgb,transmission);
fragColor.rgb = mix(clamp(hazeColor,0.0,1.0) , clamp(fragColor.rgb,0.0,1.0),transmission);
}
gl_FragColor = fragColor;
}
else // if dist < threshold no fogging at all
{
gl_FragColor = fragColor;
}
}

View file

@ -67,7 +67,7 @@ void main()
vec4 light_diffuse;
vec4 light_ambient;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight;
//float yprime_alt;
@ -195,11 +195,11 @@ if (terminator < 1000000.0) // the full, sunrise and sunset computation
if (earthShade < 0.5)
{
intensity = length(light_ambient.rgb);
light_ambient.rgb = intensity * normalize(mix(light_ambient.rgb, shadedFogColor, 1.0 -smoothstep(0.1, 0.8,earthShade) ));
light_ambient.rgb = intensity * normalize(mix(light_ambient.rgb, shadedFogColor, 1.0 -smoothstep(0.4, 0.8,earthShade) ));
light_ambient.rgb = light_ambient.rgb + moonLightColor * (1.0 - smoothstep(0.4, 0.5, earthShade));
intensity = length(light_diffuse.rgb);
light_diffuse.rgb = intensity * normalize(mix(light_diffuse.rgb, shadedFogColor, 1.0 -smoothstep(0.1, 0.7,earthShade) ));
light_diffuse.rgb = intensity * normalize(mix(light_diffuse.rgb, shadedFogColor, 1.0 -smoothstep(0.4, 0.7,earthShade) ));
}

View file

@ -117,7 +117,8 @@ float ct = dot(vec3(0.0, 0.0, 1.0), relPos)/dist;
float msl_altitude = (relPos.z + eye_alt);
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
// vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
// this is taken from default.frag
vec3 n;
float NdotL, NdotHV, fogFactor;
@ -496,8 +497,10 @@ if ((dist < 5000.0) && (combined_wetness>0.0))
// here comes the terrain haze model
float delta_z = hazeLayerAltitude - eye_alt;
float mvisibility = min(visibility,avisibility);
if (dist > 0.04 * min(visibility,avisibility))
if (dist > 0.04 * mvisibility)
{
alt = eye_alt;
@ -520,7 +523,7 @@ if (delta_z > 0.0) // we're inside the layer
if (ct < 0.0) // we look down
{
distance_in_layer = dist;
vAltitude = min(distance_in_layer,min(visibility, avisibility)) * ct;
vAltitude = min(distance_in_layer,mvisibility) * ct;
delta_zv = delta_z - vAltitude;
}
else // we may look through upper layer edge
@ -627,6 +630,7 @@ if (intensity > 0.0) // this needs to be a condition, because otherwise hazeColo
intensity = length(hazeColor);
hazeColor = intensity * normalize(mix(hazeColor, 1.5* shadedFogColor, 1.0 -smoothstep(0.25, fade_out,eShade) ));
// change haze color to blue hue for strong fogging
hazeColor = intensity * normalize(mix(hazeColor, shadedFogColor, (1.0-smoothstep(0.5,0.9,eqColorFactor))));
@ -649,7 +653,7 @@ hazeColor.rgb = max(hazeColor.rgb, minLight.rgb);
// finally, mix fog in
fragColor.rgb = mix((hazeColor)+secondary_light * fog_backscatter(avisibility) , fragColor.rgb,transmission);
fragColor.rgb = mix(hazeColor+secondary_light * fog_backscatter(mvisibility) , fragColor.rgb,transmission);
}

View file

@ -71,7 +71,7 @@ void main()
vec4 light_diffuse;
vec4 light_ambient;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight;
//float yprime_alt;
@ -194,11 +194,11 @@ if (terminator < 1000000.0) // the full, sunrise and sunset computation
if (earthShade < 0.5)
{
intensity = length(light_ambient.rgb);
light_ambient.rgb = intensity * normalize(mix(light_ambient.rgb, shadedFogColor, 1.0 -smoothstep(0.1, 0.8,earthShade) ));
light_ambient.rgb = intensity * normalize(mix(light_ambient.rgb, shadedFogColor, 1.0 -smoothstep(0.4, 0.8,earthShade) ));
light_ambient.rgb = light_ambient.rgb + moonLightColor * (1.0 - smoothstep(0.4, 0.5, earthShade));
intensity = length(light_diffuse.rgb);
light_diffuse.rgb = intensity * normalize(mix(light_diffuse.rgb, shadedFogColor, 1.0 -smoothstep(0.1, 0.7,earthShade) ));
light_diffuse.rgb = intensity * normalize(mix(light_diffuse.rgb, shadedFogColor, 1.0 -smoothstep(0.4, 0.7,earthShade) ));
}

View file

@ -120,7 +120,7 @@ void main()
{
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
@ -190,9 +190,9 @@ void main()
float delta_z = hazeLayerAltitude - eye_alt;
float mvisibility = min(visibility,avisibility);
if (dist > max(40.0, 0.07 * min(visibility,avisibility)))
if (dist > max(40.0, 0.07 * mvisibility))
{
alt = eye_alt;
@ -216,7 +216,7 @@ if (delta_z > 0.0) // we're inside the layer
if (ct < 0.0) // we look down
{
distance_in_layer = dist;
vAltitude = min(distance_in_layer,min(visibility, avisibility)) * ct;
vAltitude = min(distance_in_layer,mvisibility) * ct;
delta_zv = delta_z - vAltitude;
}
else // we may look through upper layer edge
@ -342,7 +342,7 @@ hazeColor.rgb = max(hazeColor.rgb, minLight.rgb);
// determine the right mix of transmission and haze
hazeColor = clamp(hazeColor,0.0,1.0);
fragColor.rgb = mix( hazeColor + secondary_light * fog_backscatter(avisibility), fragColor.rgb,transmission);
fragColor.rgb = mix( hazeColor + secondary_light * fog_backscatter(mvisibility), fragColor.rgb,transmission);
}

View file

@ -69,7 +69,7 @@ void main()
//vec4 light_diffuse;
vec4 light_ambient;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
float yprime;
float lightArg;

View file

@ -218,7 +218,7 @@ void main (void)
if ( random_buildings )
depthfactor = 0.0;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
float effective_scattering = min(scattering, cloud_self_shading);
vec3 normal = normalize(VNormal);
vec3 tangent = normalize(VTangent);
@ -353,8 +353,9 @@ vec3 hazeColor = get_hazeColor(lightArg);
float delta_z = hazeLayerAltitude - eye_alt;
float mvisibility = min(visibility,avisibility);
if (dist > 0.04 * min(visibility,avisibility))
if (dist > 0.04 * mvisibility)
{
alt = eye_alt;
@ -380,7 +381,7 @@ if (delta_z > 0.0) // we're inside the layer
if (ct < 0.0) // we look down
{
distance_in_layer = dist;
vAltitude = min(distance_in_layer,min(visibility, avisibility)) * ct;
vAltitude = min(distance_in_layer,mvisibility) * ct;
delta_zv = delta_z - vAltitude;
}
else // we may look through upper layer edge
@ -519,7 +520,7 @@ hazeColor *= eqColorFactor * eShade;
hazeColor.rgb = max(hazeColor.rgb, minLight.rgb);
finalColor.rgb = mix( hazeColor +secondary_light * fog_backscatter(avisibility), finalColor.rgb,transmission);
finalColor.rgb = mix( hazeColor +secondary_light * fog_backscatter(mvisibility), finalColor.rgb,transmission);
}

View file

@ -71,7 +71,7 @@ void main()
vec4 light_ambient;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight;
//float yprime_alt;
@ -199,11 +199,11 @@ if (earthShade < 0.5)
//light_ambient = light_ambient * (0.7 + 0.3 * smoothstep(0.2, 0.5, earthShade));
intensity = length(light_ambient.rgb);
light_ambient.rgb = intensity * normalize(mix(light_ambient.xyz, shadedFogColor, 1.0 -smoothstep(0.1, 0.8,earthShade) ));
light_ambient.rgb = intensity * normalize(mix(light_ambient.xyz, shadedFogColor, 1.0 -smoothstep(0.4, 0.8,earthShade) ));
light_ambient.rgb = light_ambient.rgb + moonLightColor * (1.0 - smoothstep(0.4, 0.5, earthShade));
intensity = length(light_diffuse.xyz);
light_diffuse.xyz = intensity * normalize(mix(light_diffuse.xyz, shadedFogColor, 1.0 -smoothstep(0.1, 0.7,earthShade) ));
light_diffuse.xyz = intensity * normalize(mix(light_diffuse.xyz, shadedFogColor, 1.0 -smoothstep(0.4, 0.7,earthShade) ));
}

View file

@ -91,7 +91,7 @@ void main(void)
viewerdir = vec3(gl_ModelViewMatrixInverse[3]) - vec3(gl_Vertex);
lightdir = normalize(vec3(gl_ModelViewMatrixInverse * gl_LightSource[0].position));
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
rawPos = (osg_ViewMatrixInverse *gl_ModelViewMatrix * gl_Vertex).xyz;
vec4 t1 = vec4(osg_SimulationTime*0.005217, 0.0, 0.0, 0.0);
@ -164,11 +164,8 @@ if (terminator < 1000000.0) // the full, sunrise and sunset computation
intensity = length(specular_light.rgb);
specular_light.rgb = intensity * normalize(mix(specular_light.rgb, shadedFogColor, 1.0 -smoothstep(0.1, 0.6,ground_scattering) ));
// correct ambient light intensity and hue before sunrise - seems unnecessary and create artefacts though...
//if (earthShade < 0.5)
//{
//specular_light.rgb = intensity * normalize(mix(specular_light.rgb, shadedFogColor, 1.0 -smoothstep(0.1, 0.7,earthShade) ));
//}
specular_light.rgb = intensity * normalize(mix(specular_light.rgb, shadedFogColor, 1.0 -smoothstep(0.5, 0.7,earthShade)));
// directional scattering for low sun
if (lightArg < 10.0)

View file

@ -148,7 +148,7 @@ void main(void)
{
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
float effective_scattering = min(scattering, cloud_self_shading);
float dist = length(relPos);
@ -346,7 +346,7 @@ void main(void)
specular_light = gl_Color.rgb;
specular_light = gl_Color.rgb * earthShade;
vec3 specular_color = vec3(specular_light)
@ -412,10 +412,10 @@ void main(void)
float delta_z = hazeLayerAltitude - eye_alt;
float mvisibility = min(visibility,avisibility);
if (dist > 40.0)
if (dist > 0.04 * mvisibility)
{
@ -438,7 +438,7 @@ if (delta_z > 0.0) // we're inside the layer
if (ct < 0.0) // we look down
{
distance_in_layer = dist;
vAltitude = min(distance_in_layer,min(visibility,avisibility)) * ct;
vAltitude = min(distance_in_layer,mvisibility) * ct;
delta_zv = delta_z - vAltitude;
}
else // we may look through upper layer edge
@ -496,7 +496,7 @@ else
transmission = fog_func(transmission_arg, eye_alt);
// there's always residual intensity, we should never be driven to zero
if (eqColorFactor < 0.2) eqColorFactor = 0.2;
if (eqColorFactor < 0.2) {eqColorFactor = 0.2;}
float lightArg = (terminator-yprime_alt)/100000.0;

View file

@ -196,7 +196,7 @@ void main(void)
{
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
float effective_scattering = min(scattering, cloud_self_shading);
float dist = length(relPos);
@ -555,9 +555,9 @@ void main(void)
float delta_z = hazeLayerAltitude - eye_alt;
float mvisibility = min(visibility,avisibility);
if (dist > 0.04 * min(visibility,avisibility))
if (dist > 0.04 * mvisibility)
{
@ -580,7 +580,7 @@ if (delta_z > 0.0) // we're inside the layer
if (ct < 0.0) // we look down
{
distance_in_layer = dist;
vAltitude = min(distance_in_layer,min(visibility,avisibility)) * ct;
vAltitude = min(distance_in_layer,mvisibility) * ct;
delta_zv = delta_z - vAltitude;
}
else // we may look through upper layer edge
@ -699,7 +699,7 @@ if (intensity > 0.0) // this needs to be a condition, because otherwise hazeColo
hazeColor *= eqColorFactor * eShade;
hazeColor.rgb = max(hazeColor.rgb, minLight.rgb);
finalColor.rgb = mix(hazeColor +secondary_light * fog_backscatter(avisibility), finalColor.rgb,transmission);
finalColor.rgb = mix(hazeColor +secondary_light * fog_backscatter(mvisibility), finalColor.rgb,transmission);
}

View file

@ -84,7 +84,7 @@ void main(void)
mat4 RotationMatrix;
vec3 shadedFogColor = vec3(0.65, 0.67, 0.78);
vec3 shadedFogColor = vec3(0.55, 0.67, 0.88);
rawPos = (osg_ViewMatrixInverse *gl_ModelViewMatrix * gl_Vertex).xyz;
vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex;
@ -183,6 +183,8 @@ if (terminator < 1000000.0) // the full, sunrise and sunset computation
intensity = length(specular_light.rgb);
specular_light.rgb = intensity * normalize(mix(specular_light.rgb, shadedFogColor, 1.0 -smoothstep(0.1, 0.6,ground_scattering) ));
specular_light.rgb = intensity * normalize(mix(specular_light.rgb, shadedFogColor, 1.0 -smoothstep(0.5, 0.7,earthShade)));
// correct ambient light intensity and hue before sunrise - seems unnecessary and create artefacts though...
//if (earthShade < 0.5)
//{