Skip to content

Commit 91fbe9d

Browse files
committed
Do the computation of lunar eclipse colors in nonlinear color
This legacy implementation isn't physically based, so it's OK to leave it as it used to be, until it's reimplemented in a more physical way. Fixes #3035
1 parent 486673d commit 91fbe9d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

data/shaders/planet.frag

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,13 @@ void main()
449449
if(final_illumination < 0.9999)
450450
{
451451
lowp vec4 shadowColor = texture2D(earthShadow, vec2(final_illumination, 0.5));
452-
shadowColor.rgb = srgbToLinear(shadowColor.rgb);
453-
finalColor =
454-
eclipsePush*(1.0-0.75*shadowColor.a)*
455-
mix(finalColor * litColor, shadowColor, clamp(shadowColor.a, 0.0, 0.7)); // clamp alpha to allow some maria detail.
452+
// FIXME: this should be calculated properly in linear space as
453+
// extinction of sunlight, and with subsequent tone mapping.
454+
// Current implementation is a legacy from older times.
455+
lowp vec4 color = vec4(linearToSRGB(finalColor.rgb), finalColor.a);
456+
lowp float alpha = clamp(shadowColor.a, 0.0, 0.7); // clamp alpha to allow some maria detail
457+
finalColor = eclipsePush * (1.0-0.75*shadowColor.a) * mix(color * litColor, shadowColor, alpha);
458+
finalColor.rgb = srgbToLinear(finalColor.rgb);
456459
}
457460
else
458461
#endif

0 commit comments

Comments
 (0)