Backface culling

2b4fc3c12c3723b643b76193f1a2be3d
0
Nawar 101 Jan 15, 2009 at 01:43

Hi

Iam looking into backface culling, most literature use the dot product between the surface normal and a point from the face to the camera to tell whether it is a back or front face, I found a couple of articles (which seems more logical to me) that use the dot product between the normal and the camera view vector (ie [0 0 1]) to tell whether it is a front or back face. Could anyone please explain why the majority use the first definition? Is that more “correct” and why?

Thanks for all your help
Nawar

3 Replies

Please log in or register to post a reply.

340bf64ac6abda6e40f7e860279823cb
0
_oisyn 101 Jan 15, 2009 at 02:00

Yes, the first method is correct, the second isn’t. Imagine a wall that is perpendicular to your view direction (so you’re looking at the side of the wall). Suppose the wall’s front is facing to your right. Then, if you move right, the front of the wall becomes visible. However, if you move to the left, the back of the wall becomes visible. And even though the visible features of the wall change as you move, both your and the wall’s view direction stay the same. Therefore, using merely those two variables to determine whether to cull the wall must be incorrect.

In fact, you’re not even interested in your own view direction. What matters is whether your location with respect to the wall is in front or behind it’s plane. Even if you rotate, your position with respect to the wall’s plane stays the same. So no matter your view direction, if the wall was facing you, it will continue to face you.

99f6aeec9715bb034bba93ba2a7eb360
0
Nick 102 Jan 15, 2009 at 12:07

The second method is also correct, but only after projection, in 3D homogeneous space. You can even do it later, after homogeneous division, in screen space. :ninja:

As .oisyn pointed out though it’s a very common mistake to use that method in 3D space before projection. It might look intuitive at first to compare the normal with the forward vector but that leads to incorrect results.

Anyway, none of the correct methods is “more” correct than the other. They are mathematically equivalent. They can however differ in performance and robustness. The optimal choice depends on what you’re really doing.

2b4fc3c12c3723b643b76193f1a2be3d
0
Nawar 101 Jan 16, 2009 at 01:58

Nick, .oisyn, Thank you both for your help and your quick response. Things make more sense now :-)

Cheers