Original Post
Hi GDNet. My problem is the following: I have a number of tris and quad in my scene that are used as occluders. I want to select a subset of them every frame (or every 60 frame) and one relevant criteria to do so is to compute their surface when projected on the screen. The more surface an occluder covers, the better. Practically, I am given 3 or 4 two-dimension points A,B,C(,D) that have no particular reason to form a screen aligned tri/quad What would you advise to sort these primitives in order to select only, say, the 5 best of them ? At first I thought I could calculate the exact surface, which is mathematically speaking quite easy but a little bit too computationally expensive as it implies square roots. Then I tried another approach that is to calculate the area of the AABB of the quad or triangle. while this is much more efficient, it introducies sometimes very bad approximations of the area. In particular, when a primitive is viewed at a very low angle, this approach tend to give ugly results:
A
.---------------------+--.
| |
| + B
| |
| | --> Axis Aligned Bounding Box: Bad approx of ABCD area !
| |
| |
C + |
.-+----------------------.
D
but sometimes it is good:
A
.--+---------------------.
| |
| + B
| |
| | --> Pretty good approx
| |
| |
C + |
.---------------------+--.
D
Would someone have a better approach to suggest ? Like including another factor (at the time of writing this, I just thought of using the view angle as another factor, that could be an idea... Another issue is the same bounding box can be a very good approx for a quad and a very wrong one for a triangle:
A
.--+---------------------.
| |
| + B
| |
| | --> Pretty good approx of ABCD
| |
| |
C + |
.---------------------+--.
D
A
.--+---------------------.
| |
| + B
| |
| | --> Pretty bad approx of ABC
| |
| |
C + |
.------------------------.
I thought of halving the area in case of a triangle but in a lot of cases that would be quite unfair. Thanks for reading Cheers, Janta