Atmosphere shader: auto-calculate cosThreshold based on atmosphere radius.

This commit is contained in:
AnotherCommander 2019-03-09 20:45:07 +01:00
parent f02f09b91a
commit 601128c035

View File

@ -56,17 +56,8 @@ void main()
float atmDistance = length(atmPosition.xyz);
float minDistance = atmRadius + 3500.0;
float magicDistance = atmDistance - minDistance;
float cosThreshold = 0.15; // 81.37 deg
float newOpacityExponent = 3.0;
// the outer atmosphere rim does not follow exactly the curvature of the planet for small radii
// adjust thresholds and exponents to cope for when planet radius <= 4km - note: radius is fed
// into the shader with a scale factor of 10
if (atmRadius <= 40000.0)
{
cosThreshold = 0.17; // 80.21 deg
newOpacityExponent = 5.0;
}
float cosThreshold = -1.333333e-6 * atmRadius + 0.21333333; // 0.17 ... 0.13
float newOpacityExponent = atmRadius > 40000.0 ? 3.0 : 5.0;
// mix in some light blue color
totalColor += diffuseColor * vec3(0.85, 0.85, 1.0);