I have been trying to calculate the bounding box of an object in screen space. I want to use this calculation in my shaders eventually but right now I’m unable to get it working.
I have been following the source code and calculation as described in the paper:
“2D Polyhedral Bounds of a Clipped, Perspective-Projected 3D Sphere” https://jcgt.org/published/0002/02/05/.
Here is the implementation replicated in a playground:
As you will see the calculations all lead to null coordinates. Ideally these should be bounding box coordinated that I can see in the screen space, I’ve added a post process to check the values.
Other references I’ve followed:
- zeux.io - Approximate projected bounds
- https://www.youtube.com/watch?v=Fj1E1A4CPCM&list=PL0JVLUVCkk-l7CWCn3-cdftR0oajugYvd&index=14
I maybe using the apis incorrectly, so any pointers would be really helpful.