Hey community,
Just wondering, what is the best way to calculate how much percentage of an object shown in a camera frame?
For example:
(Images below are from Maya viewport)
If an object fills up the entire camera frame from top to bottom, I hope there could be a “visibility factor (vertical)” to indicate the showing status. In the image above, the sphere is showing 100% vertically and also occupied the exact full camera frame top down. So this factor could consider as
1 in vertical direction.
And if the camera zoom further, the factor could be a value greater than 1, such as ~2.1 in the image below:
And if the camera zoom all the way into the object, it could be a factor between 0 and 1:
If zoom to as close as one vertex, the factor could be a very small positive float number almost equals to 0.
Of course, this whole idea could use bounding box points instead of actual vertex from the mesh to reduce the calculation load.
I figured out a way to detect if an object in completely inside of camera frustum (or a region of camera frustum) or not:
(PS: This PG derived from this great topic: https://forum.babylonjs.com/t/check-isinfrustum-but-with-a-percentage-of-the-camera-view/16906`)
I feel like I kind of started getting this idea working but not as accurate as I was expecting.
Does anyone have a better idea?
Many thanks,
Tawibox


