Skip to content

Commit

Permalink
Fix handling of lighting factor when rendering lunar eclipse
Browse files Browse the repository at this point in the history
Otherwise there's a visible transition between eclipse and no-eclipse
code that wasn't as visible before the switch to linear-color rendering
of planets and nonlinear handling of the eclipse.
  • Loading branch information
10110111 committed Feb 3, 2023
1 parent 9a1d058 commit 32b9957
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions data/shaders/planet.frag
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ void main()
//finalColor.xyz=mix(vec3(1., 1., 1.), finalColor.xyz, 1.-mixfactor);
finalColor.xyz=mix(vec3(1., 1., 1.), finalColor.xyz, smoothstep(0., 1., 1.-mixfactor));
}
finalColor *= litColor;
#ifdef IS_MOON
if(final_illumination < 0.9999)
{
Expand All @@ -454,14 +455,10 @@ void main()
// 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 = eclipsePush * (1.0-0.75*shadowColor.a) * mix(color, shadowColor, alpha);
finalColor.rgb = srgbToLinear(finalColor.rgb);
}
else
#endif
{
finalColor *= litColor;
}

//apply white rimlight
finalColor.xyz = clamp( finalColor.xyz + vec3(outgas), 0.0, 1.0);
Expand Down

0 comments on commit 32b9957

Please sign in to comment.