3
$\begingroup$

Is it just so you avoid unnecessary divisions or are there other advantages as well?

I've just implemented the Sutherland–Hodgman clipping algorithm and read online that you should do homogenization after clipping to avoid divisions and to "avoid messy special cases". Now I wanted to ask if someone knows what they mean by "messy special cases".

$\endgroup$
0

1 Answer 1

3
$\begingroup$

One good reason to do clipping in homogeneous space is that the perspective division loses the distinction between regions behind the camera and in front of the camera. Points in front of the camera have $w > 0$, and behind the camera $w < 0$. After dividing by $w$, points behind the camera get mapped (with a sign flip) to the same $x, y, z$ NDC space as those in front of the camera. So it is no longer possible to tell the difference; the original sign of $w$ is lost.

This implies that at least the $w$ clipping must be done in homogeneous space. For instance, triangles that have one vertex behind the camera must get clipped by the $w = 0$ plane to form a quad. Otherwise, you end up with a bizarre object called an "external triangle"—a triangle that appears in two pieces, both extending to infinity, originating from the in-front-of-camera and behind-camera regions of the original homogeneous triangle.

And I suppose that once you have to apply one of the clipping planes in homogeneous space, you might as well apply all of them there.

For further reading on this, here are a couple of good articles:

  1. In-depth: Software rasterizer and triangle clipping by Simon Yeung
  2. A trip through the Graphics Pipeline 2011, part 5 by Fabian Giesen
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.