Jump to content
  • Advertisement
Sign in to follow this  
B_old

pushing the near plane of a frustum towards an AABB

This topic is 4561 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

Hello, I have heard that shadow map precision is better the closer the near plane of the light is pushed towards the far plane. My objects have AABB for clipping. Now I would like to automatically push the near plane of the spotlight just so far that every AABB is still inside the frustum. Do you know how this can be accomplished? Thanks.

Share this post


Link to post
Share on other sites
Advertisement
I don't know much about shadow techniques, but it's quite easy to project an AABB onto a given vector. Given this, you could project all of your AABBs onto the direction vector and use the minimum and maximum values for the near and far planes.

Let me know if you need further details.

Share this post


Link to post
Share on other sites
I don't know how to project an AABB onto a vector.
What is the result of such an operation?

Share this post


Link to post
Share on other sites
A simple way to do it is to just get all 8 points of your aabbox, which are the various combinations of +- min.xyz and max.xyz, and find their distance from the plane in question with any standard point distance from plane test.

vector3 test_vector = point on box - eye point;

float distance = dot( test_vector, view direction;







Share this post


Link to post
Share on other sites
Quote:
Original post by SimmerD
A simple way to do it is to just get all 8 points of your aabbox, which are the various combinations of +- min.xyz and max.xyz, and find their distance from the plane in question with any standard point distance from plane test.

vector3 test_vector = point on box - eye point;

float distance = dot( test_vector, view direction;
Here's an easier (and faster) way:
float center = dot(box.center, axis);
float radius = dot(box.extents, axis.absolute());
min = center - radius;
max = center + radius;
The function absolute() returns a copy of the vector with each element set to its absolute value. The above assumes you have the AABBs stored in center-extents form, but if not, the conversion is simply:
center = (max + min) * 0.5f;
extents = (max - min) * 0.5f;
If you have to do the conversion every time, you may loose some of the benefits of this method, but I'd think it would still be at least as fast as the 'test each corner' approach.

Share this post


Link to post
Share on other sites
jyk:
my aabb's are set up the same way, assuming that halfspace is the same as extents.

But what do the min / max values I get, tell me?

Thanks for the help, both of you!

EDIT: what does axis stand for in your case?

[Edited by - B_old on April 21, 2006 12:06:15 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by B_old
jyk:
my aabb's are set up the same way, assuming that halfspace is the same as extents.

But what do the min / max values I get, tell me?

EDIT: what does axis stand for in your case?
As far as the problem of fitting a frustum or volume to a set of AABBs is concerned:

1. The axis in question is the 'direction' of the frustum or volume
2. Find the projection of each AABB onto this axis (just the min if you're only concerned with the near plane)
3. The normal of the near plane is the axis, and the distance is the minimum of all the 'min' values
4. The normal of the far plane is the negative of the axis, and the distance is the maximum of all the 'max' values

Share this post


Link to post
Share on other sites
I'm not sure I understand.
Is (axis, min) the near plane I'm looking for?
In that case I think I'm actually looking for the distance this plane has from my light. Because that is the value I need to construct my projection matrix.

Share this post


Link to post
Share on other sites
Quote:
Original post by B_old
Is (axis, min) the near plane I'm looking for?
For the 'fit frustum to AABBs' problem, yes.
Quote:
In that case I think I'm actually looking for the distance this plane has from my light. Because that is the value I need to construct my projection matrix.
I haven't done much with shadow rendering techniques, so I probably can't comment other than on the AABB projection issue. I'm sure others can fill in whatever's missing though.

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!