diff --git a/Shaders/skydome.frag b/Shaders/skydome.frag index 5e7178548..326fd000c 100644 --- a/Shaders/skydome.frag +++ b/Shaders/skydome.frag @@ -109,30 +109,12 @@ void main() if (sat < 0.3) sat = 0.3; - // float wscale = 1.732; -// an overexposure filter, the log() seems to be pretty expensive though - -// if (color.x > 0.8) color.x = 0.8 + 0.8* log(color.x/0.8); -// if (color.y > 0.8) color.y = 0.8 + 0.8* log(color.y/0.8); -// if (color.z > 0.8) color.z = 0.8 + 0.8* log(color.z/0.8); - - -// a different exposure filter -//color.x = 1.0 - exp(-1.3 * color.x); -//color.y = 1.0 - exp(-1.3 * color.y); -//color.z = 1.0 - exp(-1.3 * color.z); if (color.r > 0.58) color.r = 1.0 - exp(-1.5 * color.r); if (color.g > 0.58) color.g = 1.0 - exp(-1.5 * color.g); if (color.b > 0.58) color.b = 1.0 - exp(-1.5 * color.b); -// reduce the whiteout near the horizon generated by the single scattering approximation - -//if (ct > cthorizon) color = mix(color, black ,smoothstep(0.2+cthorizon, -0.2+cthorizon, ct)); -//else color = mix (color, black, smoothstep(0.2+cthorizon,-0.2+cthorizon, cthorizon)); - - // fog computations for a ground haze layer, extending from zero to lAltitude @@ -147,8 +129,6 @@ float costheta = ct; float vis = min(visibility, avisibility); -// hack - in an effect volume the visibility only may be reduced, so we take care here -//if (avisibility < visibility){vis = avisibility;} if (delta_z > 0.0) // we're inside the layer { @@ -185,9 +165,6 @@ float vis = min(visibility, avisibility); } // combined intensity reduction by cloud shading and fog self-shading, corrected for Weber-Fechner perception law - -//float scattering = ground_scattering + (1.0 - ground_scattering) * smoothstep(avisibility, 1.5 * avisibility, -alt/costheta); - float eqColorFactor = 1.0 - 0.1 * delta_zv/vis - (1.0 - min(scattering,cloud_self_shading)); @@ -201,7 +178,9 @@ vec3 hColor = hazeColor; // high altitude desaturation float intensity = length(hColor); -hColor = intensity * normalize (mix(hColor, intensity * vec3 (1.0,1.0,1.0), 0.7* smoothstep(5000.0, 50000.0, alt))); +hColor = intensity * normalize (mix(hColor, intensity * vec3 (1.0,1.0,1.0), 0.7 * smoothstep(5000.0, 50000.0, alt))); + +hColor = clamp(hColor,0.0,1.0); // blue hue hColor.x = 0.83 * hColor.x; @@ -216,10 +195,12 @@ float fade_out = max(0.65 - 0.3 *overcast, 0.45); intensity = length(hColor); vec3 oColor = hColor; oColor = intensity * normalize(mix(oColor, shadedFogColor, (smoothstep(0.1,1.0,ovc)))); -color = ovc * mix(color, oColor * earthShade ,smoothstep(-0.1+ctterrain, 0.0+ctterrain, ct)) + (1-ovc) * color; +oColor = clamp(oColor,0.0,1.0); +color = ovc * mix(color, oColor * earthShade ,smoothstep(-0.1+ctterrain, 0.0+ctterrain, ct)) + (1.0-ovc) * color; + + hColor = intensity * normalize(mix(hColor, 1.5 * shadedFogColor, 1.0 -smoothstep(0.25, fade_out,earthShade) )); hColor = intensity * normalize(mix(hColor, shadedFogColor, (1.0 - smoothstep(0.5,0.9,eqColorFactor)))); -//hColor = intensity * normalize(mix(hColor, shadedFogColor, (1.0 - smoothstep(0.5,0.9,cloud_self_shading)) )); hColor = hColor * earthShade; // accounting for overcast and saturation @@ -240,12 +221,13 @@ float altFactor2 = 0.2 + 0.8 * smoothstep(-3000.0, 0.0, delta_z); hazeBlendAngle = hazeBlendAngle + 0.1 * altFactor; hazeBlendAngle = hazeBlendAngle + (1.0-horizon_roughness) * altFactor2 * 0.1 * Noise2D(vec2(0.0,cphi), 0.3); - +terrainHazeColor = clamp(terrainHazeColor,0.0,1.0); color = mix(color, terrainHazeColor ,smoothstep(hazeBlendAngle + ctterrain, 0.0+ctterrain, ct)); // mix fog the skydome with the right amount of haze +hColor = clamp(hColor,0.0,1.0); color = transmission * color + (1.0-transmission) * eqColorFactor * hColor;