# Best way to compute BR from BB?

This topic is 696 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi

I want to find an optimized way to compute a bounding rectangle in screen space from a bounding box in 3D.

The best way I've been considering so far is to operate in homogeneous coords and project the BB vertices to screen space. For vertices behind the camera I will find the line-intersection point with the XY-plane. Then I use Liang–Barsky to compute the bounds in screen space. I would also capitalize on optimization opportunities wherever I can find them, e.g. don't look for intersection points when 2 connecting BB vertices are behind the camera.

So I just wanted to check if anyone knows of some better idea, maybe something you used? Maybe there are some methods specifically aimed for finding the BR from a BB?

Thanks!

##### Share on other sites

I've used something sort of similar.  its pretty close.

Question.  Do you need the screen bounding box orientated or its a simple axis aligned in screen space?

What are you doing in screen space, I assume its a HUD overlay?

##### Share on other sites

I've used something sort of similar.  its pretty close.

Question.  Do you need the screen bounding box orientated or its a simple axis aligned in screen space?

What are you doing in screen space, I assume its a HUD overlay?

I think it can be used in many different contexts. Right now I'm going to use it for refraction. To only copy part of the backbuffer that's covered by the objects BB.

##### Share on other sites

I've used something sort of similar. its pretty close.

Question. Do you need the screen bounding box orientated or its a simple axis aligned in screen space?

What are you doing in screen space, I assume its a HUD overlay?

I think it can be used in many different contexts. Right now I'm going to use it for refraction. To only copy part of the backbuffer that's covered by the objects BB.
In that case you want an axis aligned to the screen. I would take your 3d bounding box extents and use the wvp matrix and multiply it out. Recalc the extents in screen space as yet won't be aligned and you have your new bounding box in 2d space and clip as you have mentioned. It's quick.

Good luck

1. 1
2. 2
Rutin
20
3. 3
khawk
16
4. 4
A4L
14
5. 5

• 11
• 16
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633755
• Total Posts
3013706
×