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.

if the main problem here is not getting from world space to screen space,

this thread can help out,

here’s a pg as an example

once we get all the 6 faces of the of the bbox cube in,
we can prolly do the same thing as in your PG to shade each face black or whatever color

If you don’t wanna go through the trouble though, you can prolly just make a cube with the same dimensions and draw it on a RenderTargetTexture to get the mask?

In this topic I had given this Playground which computes ratio of the mesh seen in the camera (projecting vertices and computing 2D bounding box). If it can help…