Jump to content
  • Advertisement
Sign in to follow this  
maxest

Bounding shape projected onto the screen

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!