how to copy the data to depth buffer
Hi, i am just a beginner, so please help me
Actually, I try to copy the values in one ordinary texture to the depth buffer, how could I write the data into the depth buffer? I see the usage of texture has one type "D3DUSAGE_DEPTHSTENCIL", but I don't know how to use it.
I really appreciate if you could give me any suggestions. Thanks!
[366 byte] By [
Ethanph] at [2007-12-26]
Hi, actually I'd like to do some experiment about GPGPU, so not try some special effect :)
I have used pixel shader for this function. Then...another problem, I'd like to read the all depth values from depth buffer out, how could I do?
I guess I could first like this:
device->GetDepthStencilSurface(pSurface);
Then what can I do next? The surface seems unlockable...
Thanks!
For pixel shader usage, you can output the z coordinate of the vertex in the vertex shader and have the pixel shader interpolator (any of the texcoord registers) interpolate this value across the rasterized triangles. You can then access this value in your pixel shader...