[gameprogrammer] Re: culled objects and shadow volumes

  • From: Bob Pendleton <bob@xxxxxxxxxxxxx>
  • To: gameprogrammer@xxxxxxxxxxxxx
  • Date: Thu, 30 Apr 2009 22:51:10 -0500

On Thu, Apr 30, 2009 at 7:19 PM, Sami Näätänen <sn.ml@xxxxxxxxxxxxxxx> wrote:
> On Wednesday 29 April 2009 19:09:50 Alan Wolfe wrote:
>> Hey Sami,
>>
>> Here's what i was thinking for my final solution tell me what you think...
>> (heavily based on your idea, with a neat little twist for positional
>> lights!)
>>
>> * when an object is first known to be frustum culled, iterate through all
>> the lights that light the object (this is known inexpensively how i have it
>> set up)
>> * then for each light:
>> *   Get the vector from the light source to the object (ie starting point
>> and a vector) and make a ray from that vector, but using the objects
>> location as the origin of the ray (or, for directional lights of course
>> just use the direction vector as the vector)
>> *   Find the ray's closest point to the frustum
>> *   If the ray intersects the frustum you know it casts a shadow into the
>> frustum so remember that you need to render the shadow for this object and
>> continue onto the next light (a flag is kept for each of the possible
>> lights, up to 8 total)
>> *   If it doesn't intersect, check the distance of the closest point to the
>> frustum
>> *   If the light is directional, compare this distance to the bounding
>> sphere radius.  If it's closer than the bounding sphere radius, it could
>> cast a shadow into the frustum so remember that you need to render the
>> shadow for this object.
>> *   If the light is positional, calculate the "Radius Expansion Factor"...
>> you get this by figuring out the distance of the object to the light and
>> dividing the sphere radius by that distance.  What you have then is the
>> knowledge of how big the shadow's radius will be along the ray at any
>> distance from the light source. (ie it's the ratio that the radius of the
>> shadow grows linearly over distance)
>> *   Get the distance along the ray where the closest point to frustum is
>> and multiply that distance by the radius expansion factor to get the radius
>> of what the shadow is at that distance.  Check if that point on the ray is
>> less than the expanded distance.  If it is, then you know you have to
>> render the shadow
>>
>> What do you think, does that sound decent?
>
> One thing to consider.
>
> To catch all possibilities you need two tests for positional lights.
> 1. Nearest position to the frustum.
> 2. Furthest possible point from the object so that a normal plain in this
> point "touches" the frustum.
>
> Example of the case 2: (Frustum marked as a square to make this more clear)
> '.' is light source
> 'O' is the bounding sphere of an object.
> 'f' is area inside the frustum.
> 'F' marks the area inside the frustum where the shortest distance point from
>    the light ray can be found.
> 'S' is a special point.
>
> Using the nearest point test here tests at the corner marked with a F.
> This is correct.
>      fffff
>      fffff
>      ffffF
> .   O
>
> But the next is not, even if the vector line would go a litle bit more away
> from the frustum, than this apparently straight line down from the light
> source through the center of the bounding sphere.
>      .
>      O
>  ffffF
>  fffff
>  ffffS
>
> This is because the expansion factor of the bounding sphere is higher than the
> factor of the change in distance. The correct testing point is in the area
> marked with an S.
>
>
>> Hey also, i've been scouring my books (especially "real time collision
>> detection") and the net and have been unable to find an algorithm for
>> finding the closest point on a ray to a frustum.  Would you happen to have
>> any hints there? (:

Can this problem be reduced to the problem of finding the closet point
on a line segment to a line? Or a variation of the problem? In that
case you first compute the point on the line containing the segment to
the line. Then check to see if that point is in the segment. If so,
great, if not then which ever end of the line segment is closest to
that first point is the closest point on the line segment to the other
line.

Seems like you can treat the edges of the frustum as line segments and
treat the ray as a line segment with only one end point, and you would
quickly find the point of the line closest to a vertex or point on an
edge of the frustum. You would have to clip the ray to the frustum to
deal with cases where the ray crosses into the frustum and you might
have to special case a test for rays that are parallel to the nearest
face but intersect another face.

For that matter how much of what you need can you get from just
clipping the ray to the frustum?

Bob Pendleton


>
> I think you have to split it as separate planes and then test the distance to
> these planes. You of course need to restrict the planes, which I think is the
> hardest part.
>
> For finding the furthest possible test point touching the frustum, I think you
> could project the frustum corners to the line of the ray.
>
> This projection could be usefull for the first problem too, but I'm not sure,
> and I really don't have time now to put in to this. Although this is very
> interesting problem.
>
>
>
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>
>
>



-- 
+-----------------------------------------------------------
+ Bob Pendleton: writer and programmer
+ email: Bob@xxxxxxxxxxxxx
+ web: www.TheGrumpyProgrammer.com

---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: