Distance Fog, Depth Texture


First of all thank you for the great work you are doing with Cesium.
For my current earth visualization that I‘m trying to build I really require to apply some distance fog to the scene to improve visual appearance. It should look somehow similar to what was recently added to Google Maps satellite view.
I know that there were some plans to add such functionalities to Cesium, like e.g. here, but I can’t find any follow up on that so I tried to implement something simple by myself.

My idea was to simply use a depth texture to do the shading of distant areas.
So first I made a naive attempt to render Cesium scene to a framebuffer (color + depth) instead of canvas and them draw a simple quad with the color texture mixed with distance shading from the depth buffer, similar to this description.
But this doesn’t seem to work because Cesium is probably rendering to some frame buffers internally already.
So then I thought about drawing a quad as a simple semi-transparent overlay above Cesium scene (but still using the same GL context) and use one of the depth textures available in Cesium’s scene object. I tried out almost all of them (in ‘_context’, ‘_fxaa’, ‘_oit’ etc.) but none is giving reliable results – some work only when zoomed far away from earth but don’t refresh the content when near the surface.

Is there any depth texture stored in Cesium’s structures that could be used for this purpose?
I would very appreciate any suggestions on how this could be accomplished.

We are making a globe/terrain depth texture available to the Cesium renderer in the globe-depth branch. To start, this will be used internally by Cesium so if you use it, just a heads up that it may change from version to version without warning since it will not initially be part of the public API.

We also plan to add a post-processing framework that will support fog and other screen-space techniques (roadmap), but it is not a short-term priority.