Planar Shadows

I’m trying to find some C++ code (not pseudo / alogrithms) for projecting a shadow onto a plane (Y = 0). The light source is dynamic, and so is just about everything else - object rotation, location, etc. I know I have to use alpha blending (to draw the shadow), and a stencil buffer…but I have found no helpful code!!
Please, if you know anything…
In fact, if you’ve got a basic step-by-step method?


P.S. I’m desperate now… any info at all ?

[This message has been edited by Fugit (edited 08-09-2000).]

Ok, this piece of code got some shadow routines…

Thanks, but I already have the “dino” demos’ source…it uses a routine to project the shadow that I can’t understand - does anyone know what a shadow matrix is, or how to generate them?



The Red Book as a quick explanation of how to create shadows. The dino source provides a function for you though… Just take the function and feed it your ground plane and light position and multiply the resultant matrix onto you matrix stack and render your object(s) again. If you want you can then pop your shadow matrix off the stack, and do it again for another light.

the shadow matrix is simply a transformation that takes a point and project it on a plane using the light as reference.

You need to trace a ray from the light, to the vertices of the models and then to the plane. The intersection between the point and the ray is the position of the shadow vertex.

By doing some drawings, you can figure out the matrix with projections

stencil shadows are a whole different matter, and (i’ve read) they are a real headache.

it involves extruding your model, sorting the resulting polygons, and make two passes, one for the polys facing the viewer and another pass facing away from the viewer. the first pass adds to the stencil buffer, the second pass substracts.
use with depth buffer and no frame buffer drawing, then voila, you have a shadow masked in the stencil buffer.

i have some material about this somewhere… but its really complex…

Stencil buffered shadows and stencil buffered reflections are not the same thing Bob. Or am I just not understanding what you did?

Yeah yeah, I deleted mu post because it was just bullsh*t! Dunno what happened when I wrote it, and I don’t want anyone else to see my mistake

First, I wrote my message about shadows, but then ‘accidently’ slipped over to reflections. I apologise