Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 toglia3d   Members   -  Reputation: 138

Like
0Likes
Like

Posted 09 December 2012 - 08:12 AM

Hello!

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.

Edited by toglia3d, 09 December 2012 - 08:49 AM.


Sponsor:

#2 Hodgman   Moderators   -  Reputation: 31785

Like
1Likes
Like

Posted 09 December 2012 - 08:33 AM

What near/far plane values are you currently using?

#3 toglia3d   Members   -  Reputation: 138

Like
0Likes
Like

Posted 09 December 2012 - 08:39 AM

Right now the near plane is in 0.0001f and far is in 200.0f, but I've tried lowering the far plane to 30, lower than that I don't see the mesh. Lol

#4 toglia3d   Members   -  Reputation: 138

Like
0Likes
Like

Posted 09 December 2012 - 08:41 AM

Oh I forgot! I'm using shaders. Would have to try with the fixed pipeline to see if it gets better.

#5 Kaptein   Prime Members   -  Reputation: 2178

Like
1Likes
Like

Posted 09 December 2012 - 08:47 AM

0.0001 is a very very small near plane value!
you have lost nearly all precision at z = 40.0 with 24bits

try znear = 0.1?

you probably want to read this:
http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html
there's also a nifty calculator there!

Edited by Kaptein, 09 December 2012 - 08:52 AM.


#6 toglia3d   Members   -  Reputation: 138

Like
0Likes
Like

Posted 09 December 2012 - 08:52 AM

NOOOOOO! I can't believe this. That solved it. I was so focused on the far plane for some reason I totally forgot about the near plane. Now I know... Thanks you! Started looking way better.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS