Hi all,
in our old Direct3D 9 application we are drawing buildings onto a multisampled rendertarget. Then we draw soft particles onto a different rendertarget.
Both render passes need to use the same depth buffer, so the particles correctly disappear behind the buildings.
Here we have a problem: When the “buildings" rendertarget is multisampled, the “soft particle” rendertarget needs to be multisampled too. Otherwise they couldn't share the same depth buffer.
But this is bad for performance - the soft particles do not need multisampling.
Is there any way I could re-use the “buildings” depth buffer for the particle rendering? Here are some ideas I had:
- First render the buildings, then use StretchRect to copy the “buildings depth buffer” (which is multisampled) to a “particles depth buffer” (not multisampled). However, there is a limitation in DirectX 9 that makes this impossible: StretchRect must be called outside of a BeginScene / EndScene pair if you operate on depth surfaces.
- Call StretchRect after the frame has finished rendering. So we are re-using the depth buffer from the previous frame. When the camera moves slowly, this might be acceptable, but on quick movements it would look bad.
- Before drawing the particles, re-render the buildings (depth only) onto the “particles depth buffer”. This is bad for performance.
Are there any solutions I have overlooked?