# comp.graphics.algorithms

## Subject: Re: backface culling w/ camera question

In article ,
dfgkkdfjgddfgd@gmail.com says...
>
> Say I have a cube in my 3D scene. The camera is being moved around via
> camera matrix transformations. Its possible to "fly" the camera towards and
> past the cube so that the cube is then behind the camera.
>
> It seems like backface culling will not totally hide the cube since some of
> its faces still "face" the camera even though the camera is not pointing at
> it. How can I totally hide things behind the camera? It would seem fairly
> obvious I need to know which way the camera is pointing, but Im not sure how
> to derive this from the position and rotation information I give my camera,
> and then use it to hide faces if theyre not being viewed by the camera.
>

In case of convex objects, proper backface culling hides backfacing
polygons in an intuitive way.

Usually backface culling is explained as:
* Take a vector D from camera position P to a polygon vertex V
* Let N be the normal of the polygon
* If dot(N, D) <= 0, the polygon is backfacing (well, actually non-
frontfacing:)

While this procedure works to reduce the polygon count, you can see in a
wireframe mode that polygons that should be culled away are still
around.

The version that matches our intuition is:
* Take the vector D from camera position P to the midpoint (average) of
the vertices of the polygon.
* Proceed as above

If an object is concave, then for some view there might exist polygons
such they are front-facing but invisible. This is allright since
backface culling only promises to remove the backfacing polygons.

--
Kalle Rutanen
http://kaba.hilvi.org