PDA

View Full Version : Projected Stencil Shadows



Andrew Jameson
10-07-2007, 07:44 AM
I'm using the standard technique for projected shadows using the stencil buffer and it works very well. As the projection process uses a horizontal plane (0,1,0) then any vertical displacement of a shadow generator results in a displacement of the shadow - i.e. the rendered object and its shadow no longer meet.

A thought occured to me that I can get the shadow position to remain consistant if I move the generator during the shadow rendering phase but my maths fails me ...any ideas on how to move the x, z of the object in relation to its y position and the light source ?

I've looked at techniques like mapping but I'm working on a fairly large terrain project and I can't get the shadow resolution that I need ... any alternative methods / examples would be of interest.

Thanks

Andrew

Andrew Jameson
10-07-2007, 02:29 PM
Sorry, I hadn't made it clear that I'm using a variable height terrain hence the problem when objects move off the zero height plane. I'm sure that it's possible to make the object and its shadow coincide but there's an additional variable in the problem ... the camera position too !

Thanks

Andrew

Andrew Jameson
10-07-2007, 03:12 PM
Well after a lot more thought, I realized why the camera featured as a variable too and soon discovered how to move the shadow in relation to the light and camera ... but the geometry of the shadow isn't correct ... I thought that it would pass cursory inspection but it doesn't !

So any suggestions / links / examples on how to shadow objects on a variable height terrain ?

Andrew

thinks
10-09-2007, 02:10 AM
I suggest you search for "volumetric shadows". The problem of moving from a plane to a volume is not as trivial as you seem to have initially thought. There are many papers on this topic.

I am sorry but I don't have time to dig out references for you at this time.