Frustum Clipping

It seems we made another step in our 3D engine for now known as Agile3D. :)

So whats Frustum Clipping, lets look at the Frustum, correctly it would be camera frustum, simply its a 3D space containing all the faces that we are going to see from a camera. So to avoid rendering unnecessary faces that are outside of such frustum and we are not going to see em either way its usefull to apply some kind of determinant when face is inside or outside of the frustum.

Frustum itself is nothing more than 6 planes even though the 6th one, far plane, is rarely used. The easiest solution, once we have the planes, that comes to mind is simply checking all vertices of a specified face against all planes and check if they are at the correct side. Once atleast one of the vertices is at the correct side of each of the planes we can say that this face will be visible and needs to be projected. Easy as it sounds, there will be problems with such solution, especially with faces that intersect the near plane, things will get messy and projection will be all over the place.

This is where the Clipping part of the title comes in. To correctly handle partially visible faces (those that have atleast one of the vertices inside but not all of em) we need to split em up and render only the visible part. I am not going to technical detail but its pretty simple triangle/plane intersection although it does provide quite a space for various optimizations ;)

Personally i would avoid using any kind of clipping beside near plane which is necessary, this ofcourse depends on various things (size of the faces, polycount, etc.) its sufficient to say that in most Flash scenarios you will simply use clipping only for near plane and use all the other planes just for discarding faces that are completely outside the frustum. Below is a full frustum culling demo, without the far plane that is really unnecessary anyway.

Full frustum culling demo: DEMO

Tags:

Leave a Reply