-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Darken fog when terrain lighting is enabled. #5934
Conversation
@bagnell, thanks for the pull request! Maintainers, we have a signed CLA from @bagnell, so you can review this at any time. I noticed that CHANGES.md has not been updated. If this change updates the public API in any way, fixes a bug, or makes any non-trivial update, please add a bullet point to I am a bot who helps you make Cesium awesome! Thanks again. |
Source/Shaders/GlobeFS.glsl
Outdated
#ifdef FOG | ||
const float fExposure = 2.0; | ||
vec3 fogColor = v_mieColor + finalColor.rgb * v_rayleighColor; | ||
fogColor = vec3(1.0) - exp(-fExposure * fogColor); | ||
|
||
#if defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING) | ||
float darken = clamp(dot(normalize(czm_viewerPositionWC), normalize(czm_sunPositionWC)), 0.1, 1.0); | ||
fogColor = mix(vec3(0.0), fogColor, darken); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and where ever else just
fogColor *= darken;
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an awesome change, much needed! I agree with Cozzi's optimization and added an additional suggestion below. I use enableLighting
in a number of apps that will see automatic benefit from this.
Source/Shaders/GlobeFS.glsl
Outdated
#ifdef FOG | ||
const float fExposure = 2.0; | ||
vec3 fogColor = v_mieColor + finalColor.rgb * v_rayleighColor; | ||
fogColor = vec3(1.0) - exp(-fExposure * fogColor); | ||
|
||
#if defined(ENABLE_VERTEX_LIGHTING) || defined(ENABLE_DAYNIGHT_SHADING) | ||
float darken = clamp(dot(normalize(czm_viewerPositionWC), normalize(czm_sunPositionWC)), 0.1, 1.0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0.1
is a magic number that may not be ideal for all cases. Is it possible to add a user configuration setting for this? It won't need to change at runtime, I imagine any app that wanted to tweak it would just set their preferred value prior to initializing a viewer. But I think app authors will want control over this minimum terrain brightness value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Thanks for viewer.scene.fog.minimumBrightness
.
/ping @abwood
Darkens the fog when
viewer.scene.globe.enableLighting = true
. Here is a Sandcastle example for testing:CC @emackey