Determine percentage of screen covered by an object without using frustum culling
- by Meltac
On the CPU-side of an 3D first-person / ego perspective game I need to check whether what the players currently sees on screen is the inside of a box object defined by world space coordinates (the player might be outside of that box but on screen sees only/mostly the inside of the box, or vice-versa, looks from within the box to the outside).
The "casual" way of performing such a check would incorporate frustum culling but such an approach would be hard to achieve with my given set of engine parameters which I'd like to avoid if there is a simpler way.
What I actually have at the point where I would like to do the check (high-level script on CPU, not GPU side):
Camera world position
Camera direction
Camera FOV
Two Box corner world coordinates (left-bottom-front, right-top-back)
What I do not have right away:
View frustrum definition (near/far plane or say 6 planes defining
frustum)
Any specific pixel information (uv, view space position, depth or the
like)
What I would like to calculate:
Percentage of screen "covered" by box.
Any hints on how to perform such calculation?