Jump to content
  • Advertisement
Sign in to follow this  
stephenry

Perspective projection and z

This topic is 3255 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm am working on a standard teapot rendering application for university and I've been stuck on something for a long time. I was hoping that someone could help me out. It's at the stage now where I can see teapots when I close my eyes - not good! I'm trying to apply perspective projection to my teapot. This is pretty straight forward. I take all of the vertices (in homogeneous from) apply the perspective transformation matrix (essentially dividing w by the position of the view plane on the 'z'-axis), apply the canonical view transformation matrix (to take all vertices into the (-1,1) range) and to apply the perspective projection canonical form to parallel perspective projection canonical form transformation. After this I scale all of the vertices back by a constant multiple to convert them into (x,y) screen coordinates. This works okay for my wire-frame model but it doesn't work when I attempt to shade the model (I know that my rendering code is okay because it works whenever I disable the perspective projection code). The problem that I am having is that when ever I attempt to rasterise triangles in my model, I lose the 'z' value of points within the triangle and therefore my z-buffer code breaks. I guess the problem that I'm having is that given the three vertices of my triangle, I don't know how to interpolate (using my barycentric coordinates) to a position within the triangle (as I was doing before), because those vertices no longer share a common w-value, and therefore cannot be linearly interpolated. I've tried converting each vertice to a common 'w'-value and then performing the barycentric operation on them, but this does not appear to work. Any guidance or suggestions would be very much appreciated. Steve

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!