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.


Direct3D Z-Buffer problem


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
4 replies to this topic

#1 BMW   Members   -  Reputation: 160

Like
0Likes
Like

Posted 25 March 2013 - 11:09 PM

I am making a voxel engine in C++ with Direct3D.

 

I have rendered some voxels on the screen with colours for sides (no textures yet).

 

However it appears that the z-buffer isn't working properly. See image: (Image is of a "chunk" of blocks)

 

d3dproblem.png

 

What would be causing this?


Edited by BMW, 25 March 2013 - 11:10 PM.


Sponsor:

#2 Hodgman   Moderators   -  Reputation: 31785

Like
2Likes
Like

Posted 25 March 2013 - 11:15 PM

http://en.wikipedia.org/wiki/Z-fighting

 

You're probably using a value for the near plane that is too small. What near/far values are you using, and what's the size of your scene/objects?



#3 BMW   Members   -  Reputation: 160

Like
0Likes
Like

Posted 25 March 2013 - 11:27 PM

http://en.wikipedia.org/wiki/Z-fighting

 

You're probably using a value for the near plane that is too small. What near/far values are you using, and what's the size of your scene/objects?

I was using 0.005 for near plane, changed to 0.1, much better biggrin.png. Each block is 1x1x1.

With 0.1 there is still some very slight z-fighting, should I increase? Or will that cause it to clip too early?

 

Also, how does the near plane affect z-fighting?


Edited by BMW, 25 March 2013 - 11:27 PM.


#4 Hodgman   Moderators   -  Reputation: 31785

Like
3Likes
Like

Posted 25 March 2013 - 11:37 PM

The encoding used by the z-buffer is approximately hyperbolic, with roughly 50% of it's precision going towards values between near and 2*near. This is unfortunate  but a necessary by-product of the way that 3D perspective math works out...

Because of this, you should always set the near plane to be as large as you can tolerate, without causing clipping errors.

 

http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

http://www.codermind.com/articles/Depth-buffer-tutorial.html



#5 BMW   Members   -  Reputation: 160

Like
0Likes
Like

Posted 26 March 2013 - 02:07 AM

The encoding used by the z-buffer is approximately hyperbolic, with roughly 50% of it's precision going towards values between near and 2*near. This is unfortunate  but a necessary by-product of the way that 3D perspective math works out...

Because of this, you should always set the near plane to be as large as you can tolerate, without causing clipping errors.

 

http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

http://www.codermind.com/articles/Depth-buffer-tutorial.html

Thanks!






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