Camera problem seeing through terrain

I have reimplemented my collision detection in my voxel game I am working on and simplified some things like making my blocks be cubes with a width of 1 instead of 3. That simplifies a lot. However, I have my collision detection mostly working except when I am right up against blocks I can tilt the camera and see through slivers of the block.

I figured this is probably an easy fix but I can’t find a solution currently. Below is a screenshot. Any help is appreciated.

It’s clipping the near plane. You have two options:

  1. move the near plane closer to the camera
  2. don’t let the eye get as close to the block.

The reality is that you will likely use some combination of the above. Clearly you’d like to get closer than you are… but it’s also likely that you are currently allowed to get closer than you need to be.

And moving the near plane isn’t really free as it reduces the resolution of the z-buffer (unless you also move the far plane in)… so setting it to something ridiculously small is also not a great idea.

Decide how close you’d like the eyeball to be able to get and then move the near plane accordingly (with a little slop).

That’s science right there :smile:

I would say “wing it”, same same but different :smiley:

Also look at for information on the z-buffer precision. Maybe we should make a wiki page for this :bookmark:

Thanks guys! That helps a lot.

@DannyJo nice article(and movie quote). I might just scale my world back up. I’ll play with moving the near plane. It seems like if I move the near and far plane together then I wouldn’t get as bad of a result, but I could be wrong.

Either way that gives me a direction. Thanks!