From 56dd34a059ccd6fb9a1c1d061780377c82017e19 Mon Sep 17 00:00:00 2001 From: AnotherCommander Date: Fri, 4 Jan 2019 14:26:27 +0100 Subject: [PATCH] Added some more density to the atmospheres and slightly simplified shader in doing so. --- .../Shaders/oolite-default-atmosphere.fragment | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Resources/Shaders/oolite-default-atmosphere.fragment b/Resources/Shaders/oolite-default-atmosphere.fragment index 8e4ecb7a..93b49dbe 100644 --- a/Resources/Shaders/oolite-default-atmosphere.fragment +++ b/Resources/Shaders/oolite-default-atmosphere.fragment @@ -36,7 +36,7 @@ varying vec3 vLight1Vector; const vec3 biasColor = vec3(0.0, 0.0, 1.0); const vec3 kTerminatorThreshold = vec3(0.105, 0.18, 0.28); // old: vec3(0.1, 0.105, 0.12); -const float kFresnelExponent = 5.0; +const float kFresnelExponent = 2.0; const float biasColorMixRatio = 0.35; @@ -89,11 +89,12 @@ void main() // calculate when the atmosphere should fade in / out float quant = atmDistance < (minDistance + 2000.0) ? magicDistance / 2000.0 : 1.0; - float magFresnel = length(fresnel); - - // calculate final opacity, special handling for angles > arccos(cosThreshold) - // to fade atmosphere out at its edge - float newOpacity = NdotV > cosThreshold ? magFresnel * quant : pow(NdotV / cosThreshold, newOpacityExponent) * quant; + + // calculate the final opacity, special handling for + // angles > arccos(cosThreshold) to fade atmosphere out at its edge + float newOpacity = quant * (NdotV > cosThreshold ? + length(fresnel) * cosThreshold / NdotV : + pow(NdotV / cosThreshold, newOpacityExponent)); gl_FragColor = vec4(totalColor, newOpacity); }