culling spheres and/or boxes and when?!

Started by
1 comment, last by cozzie 11 years, 1 month ago

Hi,

'today' I've implemented my (frustum) culling as followed:

- meshes: if boundingbox is not outside frustum, render

- point lights: if boundingsphere is not oustide frustum, render

There are most likely some optimizations possible, knowing that:

- for meshes situational box versus sphere might be considered (very 'high' or 'wide' objects as a sphere is bad)

- a box check is 8 times more checking then a sphere check

I see a few options:

1 - always do sphere check first (meshes) and if 'true' afterwards do the box check

(reduces checks for sure)

2 - only do sphere checks, winning checks, possibly losing unneccesary rendering

3 - do either sphere or box, based on a precalculated bool which one to do, for example if width is more then 'x'% of height and depth (and vice versa)

Another thing I consider is keeping track of my camera being moved or rotated, and only if TRUE, update visibility through checking everything against the frustum.

Really like to hear your thoughts on these 'dilemma's.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

Advertisement
Culling is not usually a performance problem unless you have a huge number of objects, and then the best optimisation is to use a hierarchy to allow many objects to be rejected with a single test.

Accuracy is important however, and box tests (axis-aligned or rotated) are better than spheres on that score. It isn't worth branching, pick one and do everything the same way.

Finally, a box test is not eight times more expensive than a sphere test. You're checking all the corners, aren't you? You only need to find the extents of the box along the plane normal.

Hi ewclay.

Thanks for your reaction, clear. Pick one (sphere or box) and use it only (not both). And afterwards, inplement hierarchy to reject early for 'groups' (within a node/ area).

Do you mean for the boundingbox I could only check the points (min_x, min_y, min_z) and (max_x, max_y, max_z).

When thinking about it it might (will) indeed give the same results with way less checks.

Do I understand correct?

If so, I'll go for spheres with point lights and bounding box with meshinstances.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

This topic is closed to new replies.

Advertisement