Skip to content

Commit

Permalink
Change CentralBodyFS to apply the night texture after the ground atmo…
Browse files Browse the repository at this point in the history
…sphere, because otherwise the night lights can never be shown with ground atmosphere turned on.
  • Loading branch information
emackey committed May 14, 2012
1 parent f876322 commit f01df9e
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions Source/Shaders/CentralBodyFS.glsl
Expand Up @@ -257,36 +257,29 @@ void main()
float cloudCover = 0.0; // No clouds
#endif

vec3 rgb;
vec3 rgb = dayColor(normalEC, txCoord, cloudCover);

#ifdef SHOW_GROUND_ATMOSPHERE
const float fExposure = 2.0;
vec3 color = v_mieColor + rgb * v_rayleighColor;
rgb = vec3(1.0) - exp(-fExposure * color);
#endif

#ifdef SHOW_NIGHT
if (diffuse > u_dayNightBlendDelta)
{
// Day time
rgb = dayColor(normalEC, txCoord, cloudCover);
}
else if (diffuse < -u_dayNightBlendDelta)
if (diffuse < -u_dayNightBlendDelta)
{
// Night time
rgb = nightColor(txCoord, cloudCover);
}
else
else if (diffuse <= u_dayNightBlendDelta)
{
// Dusk/dawn
rgb = mix(
nightColor(txCoord, cloudCover),
dayColor(normalEC, txCoord, cloudCover),
rgb,
(diffuse + u_dayNightBlendDelta) / (2.0 * u_dayNightBlendDelta));
}
#else
rgb = dayColor(normalEC, txCoord, cloudCover);
#endif

#ifdef SHOW_GROUND_ATMOSPHERE
const float fExposure = 2.0;
vec3 color = v_mieColor + rgb * v_rayleighColor;
gl_FragColor = vec4(vec3(1.0) - exp(-fExposure * color), 1.0);
#else
gl_FragColor = vec4(rgb, 1.0);
#endif
}

1 comment on commit f01df9e

@pjcozzi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Next time please make a change like this on a separate branch and pull request it in, especially if it needs a code review.

Please sign in to comment.