Jump to content
  • Advertisement
Sign in to follow this  
Tispe

Render-To-Texture and Z-buffer issues

This topic is 2079 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

Hello

 

I have followed the this guide http://www.two-kings.de/tutorials/dxgraphics/dxgraphics16.html to render to a texture.

 

I have no trouble rendering to the backbuffer. But when I swap out the backbuffer with a surface from a texture the z buffer does not work. I keep everything else the same except the render target. I can draw the colors, view/perspective just fine, but there are no depth test going on even though all states are the same.

 

The clear function returns with no errors and every draw is within a begin() and end(), just like with the backbuffer as target.

device->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(255, 255, 255), 1.0f, 0);
device->CreateTexture(512, 512,
		1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8,	//D3DFMT_R32F
		D3DPOOL_DEFAULT, &pShadowMapTexture, NULL);

What could cause this?

Share this post


Link to post
Share on other sites
Advertisement

The depth buffer is created with these present parameters way before this texture is created:

pp.AutoDepthStencilFormat = D3DFMT_D24S8; //D3DFMT_D24X8 also not working

D3DFMT_X8R8G8B8 is the format for the texture, which holds the surface I want to render to, it is not the depth buffer format. I tried D3DFMT_R5G6B5 as in the tutorial but it didn't work either.

Share this post


Link to post
Share on other sites

Fixed it -.-

pp.MultiSampleType = D3DMULTISAMPLE_NONE;

 

 

  • The multisample type must be the same for the render target and the depth stencil surface.

Share this post


Link to post
Share on other sites

Just don't have it bigger it says. But I guess I need to make an additional zbuffer for the new render target, because now my edges are jagged.

 

Or is it possible to create a Texture with D3DUSAGE_RENDERTARGET and D3DMULTISAMPLE_8_SAMPLES?

Edited by Tispe

Share this post


Link to post
Share on other sites

Is it possible to change the MultiSampleType of a surface inside a IDirect3DTexture9?

 

I don't want to render to a surface and then have to StretchRect to place it into the shadow map texture as a work around for the zbuffer/render target compability issue.

 

The IDirect3DTexture9::GetSurfaceLevel method returns the Address of a pointer to an IDirect3DSurface9 interface. Would DirectX be upset If I grabbed the surface, released it twice and created a new surface using the same pointer using the IDirect3DDevice9::CreateRenderTarget method?

Edited by Tispe

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!