Writing to the Z-buffer.

Started by
3 comments, last by dhanji 19 years, 8 months ago
Is it possible to write a "pre" defined array of values to the Z-buffer in DirectX? I know it can be done in opengl using: glDrawPixels(width, height, GL_DEPTH_COMPONENT, GL_FLOAT, myPtrToASavedZBufferAsFloats); Is there a directX equivelent?
Advertisement
If your depth format is D16_LOCKABLE, then I suppose you could lock and write a predefined images. Other than that, no, I don't think you can... but I'm not certain.
My guess would be to use IDirect3DDevice9::GetDepthStencilSurface() to get a pointer to the depth/stencil surface. Then, you could use D3DXLoadSurfaceFromMemory() to copy data straight from memory to the depth/stencil surface. Then just release the surface and go back to rendering. Just a guess, though; I can't guarantee that it'd work. And if you wanted to write only the depth stuff, and preserve the stencil stuff (assuming you even have stencil stuff), then you'd probably have to call IDirect3DSurface9::LockRect() and copy the data over manually.

[edit]If the default depth/stencil surface isn't lockable, you might be able to manually create one, and set up your own swap chain. As above, though, I don't really know if it'd work or not.[/edit]
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke
Quote:Original post by Agony
My guess would be to use IDirect3DDevice9::GetDepthStencilSurface() to get a pointer to the depth/stencil surface. Then, you could use D3DXLoadSurfaceFromMemory() to copy data straight from memory to the depth/stencil surface. Then just release the surface and go back to rendering.

Keep in mind that'd still require a lockable depth buffer.

Quote:Keep in mind that'd still require a lockable depth buffer.


couldnt you set the depth stencil as a render target and write to it through the render pipeline?
something like,

D3DUSAGE_DEPTHSTENCIL | D3DUSAGE_RENDERTARGET

sounds a bit farfetched... =)
________________
"I'm starting to think that maybe it's wrong to put someone who thinks they're a Vietnamese prostitute on a bull"       -- Stan from South Park
Lab74 Entertainment | Project Razor Online: the Future of Racing (flashsite preview)

This topic is closed to new replies.

Advertisement