# Bounding shape projected onto the screen

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

## Recommended Posts

I simply build a bounding box for a light's sphere. And I project the box's vertices onto the screen to get constraints for scissor test. And here come problems. Especially when camera is somewhere near/in the bounding box. Projected vertices get huge values, they got twisted and so on. I realized that the problem is with the "world behind the camera which gets inversed because of perspective projection". So, with some simple piece of code:
if (corners.z < 0.0f || corners.z > 1.0f)
{
corners.x *= -1.0f;
corners.y *= -1.0f;
}

I was able to "correct" this. Another problem was with scissoring when the light's bounding box was behind the camera. The scissor doesn't take care of Z bounds so the scissor's region was visible in screen space. Using simple camera-light's_bounding_box occlusion took care of it. The second problem I cannot win with is that somewhere very close to light's sphere, projecting vertices onto the scren just doesn't work - a noticeable part of light's sphere is being "scissoried". So, after this short speech, my question is: how do you determine scissor region?

##### Share on other sites
youre better off projecting the sphere to the screen to use for the scissortest

IIRC humus's basecode has an example
http://www.humus.name/

##### Share on other sites
Well, I've just implemented Lengyel's algorithm which bounds the sphere. I find the points of tangency and project them onto the screen. And when I'm close to the sphere it messes up. Is there some "elegant" way to solve this projection problem?

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633737
• Total Posts
3013612
×