This topic is now archived and is closed to further replies.


how do I use the same depth buffer for two colour buffers?

Recommended Posts

talby    122
hi, I''m trying to do per-pixel lens flare line of sight checking. My solution involves the use of a second colour buffer, but keeping the existing z-buffer. 1) for argument''s sake both colour buffers are 512x512 X8R8G8B8 2) I''m using d3ddevice->SetRenderTarget( myColourSurface, device->GetDepthStencilSurface() ) Anyway, the problem is when I draw to the new render target, the depth buffer is garbage! Just by drawing a single white quad at z=0.9999999 I get random noise. Does anyone know why I wouldn''t be able to use the existing depth buffer with a new colour buffer? and i quote ( from the DX8 help file ), "The previous depth-stencil surface''s contents persist after a call to SetRenderTarget to disassociate the previous depth-stencil surface from the device. If the surface is re-associated with the device, then the contents of the surface will be unchanged, providing the color buffer to which the new depth-stencil surface is being paired is the same size and format as the color buffer to which the depth-stencil surface was most recently paired"

Share this post

Link to post
Share on other sites