Fog color and the atmosphere

Hello everyone,

I’m making a map where the terrain is covered by snow.

When tilting the camera, the fog that is seen on the mountains for some reason has a reddish yellow hue, and I’d like it to be blue.

var transparentBaseLayer = new Cesium.SingleTileImageryProvider({
url: “data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNgYAAAAAMAASsJTYQAAAAASUVORK5CYII=”
});

var cesiumTerrainProviderMeshes = new Cesium.CesiumTerrainProvider({
url : ‘https://assets.agi.com/stk-terrain/world
});

var viewer = new Cesium.Viewer(‘cesiumContainer’, {
imageryProvider : transparentBaseLayer,
terrainProvider : cesiumTerrainProviderMeshes,
baseLayerPicker: false
});

viewer.scene.globe.baseColor = new Cesium.Color(1,1,1);

``

I’m aware that there isn’t any color property implemented for the Fog for now, but I’ve found this “In Cesium, the fog is a blend of the atmosphere color and the terrain on the horizon” in a Cesium blog post.
However, no matter which color I apply to the atmosphere (with the terrain being white), the fog is still yellow. I don’t get where this yellow color is even coming from.

I also tried to remove the atmosphere and set a blue skybox, with no success.

Can anyone help me with this?

Thank you!

Hello,

There currently is not a way to set the fog color. It is based on the default atmosphere color and does not currently take into account any atmosphere color shift you may have applied.

We have this GitHub issue open to look into this: https://github.com/AnalyticalGraphicsInc/cesium/issues/4195

I added a link to your forum post so we can notify you when we get a chance to look at it.

In the meantime, you can manually edit the fog shader to make the fog the color you want. See this line: https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Shaders/Builtin/Functions/fog.glsl#L18

For example, if you replace fogColor with vec3(1.0, 0.0, 0.0) you will get red fog.

See our build guide for instructions on downloading and building the code base: https://github.com/AnalyticalGraphicsInc/cesium/tree/master/Documentation/Contributors/BuildGuide

Best,

Hannah

That is very helpful, thank you!

Hi Camila, you can now set the fog color with

viewer.scene.globe.atmosphereHueShift
viewer.scene.globe.atmosphereSaturationShift
viewer.scene.globe.atmosphereBrightnessShift

``

Some combination of saturation and brightness should create the effect you’re looking for: Demo link

This functionality will be included in Cesium 1.51 on November 1st.