Jump to content
  • Advertisement
Sign in to follow this  

No Z-buffering when rendering to texture

This topic is 3984 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

When I render to a texture in my program there is no z-buffering. The objects that I drew last are in front and faces or subsets that are supposed to be behind are rendered in front. When I switch back to not using a render target everything works fine. What is the problem here? Here is the code for creating and setting the render target:
    g_pD3DDevice->CreateTexture(width,
								height,
								1,
								D3DUSAGE_RENDERTARGET,
								d3ddm.Format,
								D3DPOOL_DEFAULT,
								&scene,
								NULL);
    scene->GetSurfaceLevel(0,&pRenderSurface);
    g_pD3DDevice->SetRenderTarget(0,pRenderSurface);

Then I render everything and put this texture up on a fullscreen quad. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Check out the d3d debug warnings, I bet there will be one in there warning that your color buffer doesn't match your depth buffer, and therefore the depth buffer isn't being used.

Share this post


Link to post
Share on other sites
I actually just formatted my hard-drive and don't have the debug runtime installed currently. I would if it weren't for dial-up :(

Anyways, I'm doing this debugging blind which is probably bad but... So you say that the depth buffer probably doesn't match the color buffer. Does this mean that the texture is storing the color buffer as well as the depth buffer? I already set the texture format to be the same as the back buffer format. Could the problem be with dimensions? What other stuff might not match or cause a problem?

Thanks.

Share this post


Link to post
Share on other sites
It could quite possibly be a Power of Two problem. Check your device capabilities, specificly the TextureCaps of D3DCAPS9 to see if your device is compatible with non-power of two textures. AND TextureCaps with D3DPTEXTURECAPS_POW2, if it is not set, then your device is compatible with non-power of two textures. If it is set, then check the D3DPTEXTURECAPS_NONPOW2CONDITIONAL flag.

If it is set, then, according to the DirectX documentation, the device is compatible with non-power of 2 textures as long as the following conditions are met:

- The texture addressing mode for the texture stage is set to D3DTADDRESS_CLAMP.
- Texture wrapping for the texture stage is disabled (D3DRS_WRAP n set to 0).
- Mipmapping is not in use (use magnification filter only).
- Texture formats must not be D3DFMT_DXT1 through D3DFMT_DXT5.

If all this fails, try changing the size of the texture your creating to a width and height that are a power of two. (They dont need to be the same power of two)

Share this post


Link to post
Share on other sites
i had same problem here:
http://www.gamedev.net/community/forums/topic.asp?topic_id=448564
but still no answers there, i'll look here.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!