Skip to content
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

Merged
merged 4 commits into from
Oct 27, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Change Log
* Added `customTags` property to the UrlTemplateImageryProvider to allow custom keywords in the template URL. [#5696](https://github.com/AnalyticalGraphicsInc/cesium/pull/5696)
* Improved CZML Reference Properties example [#5754](https://github.com/AnalyticalGraphicsInc/cesium/pull/5754)
* Fixed bug with placemarks in imported KML: placemarks with no specified icon would be displayed with default icon. [#5819](https://github.com/AnalyticalGraphicsInc/cesium/issues/5819)
* Fix bright fog when terrain lighting is enabled. [#5934](https://github.com/AnalyticalGraphicsInc/cesium/pull/5934)

### 1.38 - 2017-10-02

Expand Down
6 changes: 5 additions & 1 deletion Source/Shaders/GlobeFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,16 @@ void main()
vec4 finalColor = color;
#endif


#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);
Copy link
Contributor

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.

fogColor = mix(vec3(0.0), fogColor, darken);
Copy link
Contributor

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;

?

#endif

gl_FragColor = vec4(czm_fog(v_distance, finalColor.rgb, fogColor), finalColor.a);
#else
gl_FragColor = finalColor;
Expand Down