Sign in to follow this  

Triangle rasterization confusing special case

This topic is 2325 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
[quote name='Trienco' timestamp='1312520037' post='4844868']
It's called clipping and googling for that and/or Sutherland Hodgeman should point at a very common solution.
[/quote]

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

This topic is 2325 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this