Skip to content

Commit

Permalink
Do the computation of lunar eclipse colors in nonlinear color
Browse files Browse the repository at this point in the history
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
  • Loading branch information
10110111 committed Feb 1, 2023
1 parent 486673d commit 91fbe9d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions data/shaders/planet.frag
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,13 @@ void main()
if(final_illumination < 0.9999)
{
lowp vec4 shadowColor = texture2D(earthShadow, vec2(final_illumination, 0.5));
shadowColor.rgb = srgbToLinear(shadowColor.rgb);
finalColor =
eclipsePush*(1.0-0.75*shadowColor.a)*
mix(finalColor * litColor, shadowColor, clamp(shadowColor.a, 0.0, 0.7)); // clamp alpha to allow some maria detail.
// FIXME: this should be calculated properly in linear space as
// extinction of sunlight, and with subsequent tone mapping.
// Current implementation is a legacy from older times.
lowp vec4 color = vec4(linearToSRGB(finalColor.rgb), finalColor.a);
lowp float alpha = clamp(shadowColor.a, 0.0, 0.7); // clamp alpha to allow some maria detail
finalColor = eclipsePush * (1.0-0.75*shadowColor.a) * mix(color * litColor, shadowColor, alpha);
finalColor.rgb = srgbToLinear(finalColor.rgb);
}
else
#endif
Expand Down

0 comments on commit 91fbe9d

Please sign in to comment.