[gameprogrammer] Re: culled objects and shadow volumes

  • From: Alan Wolfe <alan.wolfe@xxxxxxxxx>
  • To: gameprogrammer@xxxxxxxxxxxxx
  • Date: Wed, 27 May 2009 08:45:31 -0700

I haven't tackled this yet, i've been working on other features and optimizing.

i'll post back when i get it in though (:

I hit another snag with shadows.  I did a lighting pass on our first
area and basically it made it so that most things were in the shadow
of a light source, while being illuminated by another.

Since i was just darkening shadows 50% against black, this gave really
wrong rendering results so i disabled shadows for now in that area.

I'm thinking i'm going to change it to do the multipass shadow
rendering where you render the scene once with only ambient lighting,
then for each light calculate the shadow volumes and render the
objects it affects with additive blending of the lit surfaces.

It's going to be a performance hog doing multiple passes but not sure
what else to do :P

(screenshots if interested http://project1.demofox.org/)

On Wed, May 27, 2009 at 6:04 AM, Sami Näätänen <sn.ml@xxxxxxxxxxxxxxx> wrote:
> On Friday 01 May 2009 03:37:21 Alan Wolfe wrote:
>> interesting about the point lights, you are right.
>>
>> Someone suggested i make use of the vornoi regions of the frustum to find
>> the closest point of the ray (ie get the closest point in each region then
>> take the winner overall)
>>
>> Your projection of the corners onto the ray sounds intriguing (:
>
> Did you find a solution to this?
> And if you did, was it efective enough?
>
>> On Thu, Apr 30, 2009 at 5: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? (:
>> >
>> > 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
>
>
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>
>
>

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


Other related posts: