Original Post
Hi everyone, I have a couple questions. I have a OpenGL background and just trying to figure out how multiple render targets, rendering to texture and using depth as a texture works in DirectX. I made couple searches and found useful docs about these topics, but I got stuck in some questions... I am trying to create a texture with "D3DUSAGE_DEPTHSTENCIL" flag and using It's surface as depthstencil surface with "device->SetDepthStencilSurface(depthsfc)". And setting color render targets with "device->SetRenderTarget(0,colorsfc)". Problem is when I try to render a quad on screen with that depthtex , it renders with red and black colors and if I use debug version of DirectX it says lots of these when setting texture: ASSERTION FAILED! File E:\dxsdk\wggt_apr07\Private\MultiMedia\DirectX\dx\d3d9\fw\texture.hpp Line 71: GetBufferDesc()->Format == GetUserFormat() If I use colortex instead of depthtex, no problem occurs. So I think, using that depthtex as a texture for rendering objects is illegal. Another question is render targets. In DepthOfField example in DX sdk, they used D3DXCreateRenderToSurface api to create a "render to surface" for old cards. Do I really need it, or is it a just wrapper? Also It seems it has a new depthbuffer for itself, how can I dump it's depth buffer? These things was easy in opengl but it seems a little complicated in DX. --== Summary =-- How can I render depth of offscreen render result to a quad, or use it on shaders as texture or copy it's contents to system memory? (it can't be lockable so how can i read it or use as actual texture?) How to get depth from Render To Surface that created with D3DXCreateRenderToSurface? Thanks for reading and help...