Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 22 Oct 2007
Offline Last Active Feb 20 2013 10:06 AM

Topics I've Started

Very imprecise z buffer testing in self occluding mesh created on runtime

09 December 2012 - 08:12 AM


So, I'm doing a tree like mesh generator using Directx 9 with vertex and index buffer objects and I'm getting terrible z buffer testing with it. I'm not even sure what this is related too, maybe someone can point out where to start tweaking?

Posted Image

I leave some code that might be relevant to the viewer:

[source lang="cpp"]D3DDISPLAYMODE d3ddm;g_pD3D->GetAdapterDisplayMode( D3DADAPTER_DEFAULT, &d3ddm );g_d3dpp.Windowed = TRUE;g_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;g_d3dpp.MultiSampleType = D3DMULTISAMPLE_8_SAMPLES;g_d3dpp.BackBufferFormat = d3ddm.Format;g_d3dpp.EnableAutoDepthStencil = TRUE;g_d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;[/source]

AutoDepthStencilFormat seems to be very relevant but i cant go higher than D24 or my app crashes in stuff like:
[source lang="cpp"]d3dDevice->SetRenderState(D3DRS_ZENABLE,true);[/source]

I have these two guys enabled:
[source lang="cpp"]d3dDevice->SetRenderState(D3DRS_ZENABLE,true);d3dDevice->SetRenderState(D3DRS_ZWRITEENABLE,true);[/source]
I have also tried tweeking the near and far planes of my frustrum in:
[source lang="cpp"]D3DXMatrixPerspectiveFovRH[/source]
But I don't getter better results. Don't know where else to tweak.

Thanks for your help.