Depth-based screen-space effects and multisampling


I would like to know, how do you concern with edge problems, appearing when you get back screen depth texture and use it after in some calculations (like transparency, volumetric fog or smth like that).

The problem’s nature is evident - texture we got looses information about individual fragments/samples, coveraged by pixel. So, we may got huge discontinuity in our screen-space function we’re applying with above mentioned depth texture.

The solution we’ve been used up to now - is to disable multisampling, render to FBO with 2x sizes, and minify back to match the screen. But this surely has disadvantages - the most important growing fill-rate. So, better solutions are desired.

Any comments are very much appreciated!

The GPU Gems 3 “High-Speed Off Screen Particles” approach seems to work pretty well for fog/smoke/fuzzy effects. Basically, use low-res particles for the bulk of the scene, but around edge discontinuities use the full-res. Mask between these using stencil.

However, this doesn’t really address your base question, which is how to fully take advantage of an MSAA depth buffer. You might look at the Acquiring Depth and Downsampling Depth sections in that article for some ideas.

Dark Photon,

thank you, I will have a look there.

Actually, we have no problems with particles. Main problems are with effects like full-screen fog calculation (atmospheric scattering, underwater rendering and so on).

GPU Gems 2 features an article about defferend shading in STALKER. They solved the issue with an edge detection filter to achive anti aliasing. Mabye thats what your searching for. (The article has been released on the nvidia developer page for free)

The GPU Gems 3 article describes something similar. IIRC using a Sobel filter on the depth texture to find edges and seed the stencil mask, then just render high-res there.

FWIW, the only hardware that I know of that is capable of a true multisample depth resolve (manual or otherwise) is the ATI HD3000, but afaik that’s DX 10.1 only.

We’ll surely see this capability across the board in Mount Evans or thereabouts.