Previous and most likely Cull

• 06-19-2009, 10:12 PM
Diniden
Previous and most likely Cull
Another optimization I thought I'd mention is previous culling. This applies to frustrum culling.

Assign each face of your frustrum an integer (left side = 1 top = 2 right = 3 etc)

Now, when a vertex is culled by the frustrum, it stores which side it was last culled on. On next frame of rendering the face first checks it's previous side it was culled on since by probability it will be culled again on the same side (if the camera isn't thrashing around in large intervals).

Next, if the camera rotates right, then the most likely candidate would be the left side so in your frustrum cull set a parameter to have priority in checking the left side.

So, first check the previous cull, then check the most likely candidate, then just check what's left over in any order.

If the face is not culled then it receives a 0 as it's previous cull. Of which it will just check the most likely candidate first then check the rest in any order.

I have tested and have on average reduced frustrum cull calculations by 25% or more depending on the circumstances. It never seems to cost more than it's worth though. So might be useful to implement if you're trying to make an engine :P

EDIT: I changed something. It's not the face that stores what side it was tested on, it's every vertex that stores what side it was on.
• 06-23-2009, 03:26 AM
Diniden
And I did some reading and apparently this technique I mentioned is used in quad trees. So, just leave the memory of which side the quad was culled on and repeat that test first.

But, you can also make use of my most likely cull idea I mentioned in quad trees. This could help speed up the action of rotating the camera.