Jump to content
  • Advertisement
Sign in to follow this  
yahastu

Triangle rasterization confusing special case

This topic is 2543 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

I've written my own triangle rasterization engine, and I ran into an interesting special case that I can't figure out how to solve.

The situation occurs when rendering a triangle that has 1 or more vertices in front of the camera in the visible area, AND 1 or more vertices behind the camera. In this case, the vertex that is behind the camera has a -z value as a homogeneous point, and when converting back into inhomogeneous coordinates it gets negative values that make no sense for the purpose of rasterization.

It seems that in order to resolve this issue, it will be necessary to detect where the triangle crosses the border of the screen and split the on-screen portion into 2 valid triangles. However, I'm not sure how to calculate the vertex data at these newly created vertices on the edge of the screen from the original vertex.

Share this post


Link to post
Share on other sites
Advertisement
I'm pretty sure that's what openGL/directx do, I'm pretty sure there'll be documentation somewhere on the algorithim

Share this post


Link to post
Share on other sites
It's called clipping and googling for that and/or Sutherland Hodgeman should point at a very common solution.

Share this post


Link to post
Share on other sites

It's called clipping and googling for that and/or Sutherland Hodgeman should point at a very common solution.


Thanks Trienco, that's exactly the solution I was looking for! And as for interping the vertex data, I suppose that's fairly straight forward linear interp just like in rasterization.

Share this post


Link to post
Share on other sites
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!