Z-Buffer Question

Ok, I've got a newb question. I'm working on a z-buffered renderer project and if I rotate the view around the origin so that you're now looking down the positive z-axis my z-buffer breaks because it expects to be looking down the negative z-axis. Obviously there has to be a more robust method for doing this because it doesn't make any sense to have to check which direction you're looking and flip the comparison based on that.

I'm obviously doing something wrong but I have no clues where to start.
 
Well, you shouldn't have to flip the comparison unless you flip the z direction in the projection matrix. Which way you're looking in world space should not make it so that you to have to flip the comparison, unless your matrix is broken somehow.
 
Ok, here's something weird, the test case that it was failing on previously had the near plane set to 7.5 and far to 1000

When I changed the near plane to be 1 it suddenly started working again. Any new ideas? And this certainly brings my matrices into question.

Edit: Ok, it looks like I've narrowed it down some more. I need to go back and review my lookat function and make certain I've implemented that properly.

Thank you Humus, and any others who've read this.
 
Last edited by a moderator:
Definitely sounds to me like you've got something strange going on with your matrices - thankfully there's a huge amount of information available on this subject, so it shouldn't be too hard to track down ;)

Jack
 
Back
Top