On 22/03/2008, Ian Mallett <[EMAIL PROTECTED]> wrote: > Hasn't anyone figured this out? One would think that it can't be too > difficult. One quad over another--how hard could it be?
It's pretty easy really, when you consider that opengl is a system designed around the idea of projecting 3d coordinates into 2d coordinates in a plane, based on a transformation matrix. When you draw your world, you project the 3d geometry into the screen plane based on the eye point. When you draw the shadows, you project the 3d geometry into the shadowed surface plane, based on the light source point. So, you see, it's exactly the same thing. This has the following implications: * A shadow can no more have a soft edge than a polygon can have a soft edge. You can fake it by doing multiple samples, but then you have to draw everything multiple times. Doing this for your shadow rendering gives you the penumbra(1) effect, doing it for your world view gives you a depth of field(2) effect. * If every triangle can shadow every other triangle, then rendering the shadows requires drawing n*n*l triangles where n = number of triangles and l = number of light sources. You have to do this for every single sample you do, if you are trying to do soft shadows. Of course, you can optimize using depth tests, bounding boxes etc. But then you are getting into the kind of complex algorithms(3) that take people years to perfect... (1) http://en.wikipedia.org/wiki/Umbra (2) http://en.wikipedia.org/wiki/Depth_of_field (3) http://graphics.cs.lth.se/research/shadows/ -- Alistair Buxton [EMAIL PROTECTED]