Sign in to follow this  
yahastu

Triangle rasterization confusing special case

Recommended Posts

yahastu    154
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
yahastu    154
[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

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