Write depth buffer to texture
Posted
by
innochenti
on Game Development
See other posts from Game Development
or by innochenti
Published on 2012-03-18T11:45:06Z
Indexed on
2012/03/18
18:24 UTC
Read the original article
Hit count: 193
I need to read depth buffer from GPU and write it to texture. How this can be done? Here is how texture for depth buffer is created:
depthBufferDesc.Width = screenWidth;
depthBufferDesc.Height = screenHeight;
depthBufferDesc.MipLevels = 1;
depthBufferDesc.ArraySize = 1;
depthBufferDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
depthBufferDesc.SampleDesc.Count = 1;
depthBufferDesc.SampleDesc.Quality = 0;
depthBufferDesc.Usage = D3D10_USAGE_DEFAULT;
depthBufferDesc.BindFlags = D3D10_BIND_DEPTH_STENCIL;
depthBufferDesc.CPUAccessFlags = 0;
depthBufferDesc.MiscFlags = 0;
m_device->CreateTexture2D(&depthBufferDesc, NULL, m_depthStencilBuffer);
Also, I've got another question: is it possible to bind depth buffer texture as sampler to the pixel shader?
© Game Development or respective owner