Direct3D Z-Buffer problem

Started by
3 comments, last by BMW 11 years, 1 month ago

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?

Advertisement

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?

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?

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

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!

This topic is closed to new replies.

Advertisement