a shadow production algorithm

I am attempting to find/create an algorithm in order to develop finite volume shadow rendering for any solid & for any number of lights. I wish to utilize the opengl matrix multiplications to optimize this process.

so far here is what I have devised.

make an orthoganal projection of the 3d object from the perspective of the light source.

perform a convex hull operation on this 2d projection.

take these resultant vertecies and compute the vectors between each and the light source.

based upon the brightness and attenuation of the light source determine the last relevent point on the projected vector.

form an edge from the two points on this vector (the one on the solid and the one projected) and combine them with the other computed edges to produce a solid.

use a collision detection algorithm to determine which other objects the shadow volume intersects and where they intersect on those objects.

construct a polygon of the same color as the object to paste over the intersected surface. compute the lighting for this polygon as if the light source did not exist.

if it is a point light source the shadows will be sharp but if the light source has a surface area the edges will be soft and of a varying degree of thikness depending on the surface area of the light source and the distance the object is from the light and the distance the object is from it’s shadow.

once this operation is computed the resulting scene will fit into the pipeline until a change is made.

is this an acceptable algorithm for real time shadow mapping if it is selectivly computed for objects which take up more space in the scene than others?

do you have any Ideas on how I could make this algorithm fit into the pipline better?

thanks for your input.

-Collin Schroeder

First, the matrix multiplies in OpenGL are typically done on the CPU, not the GPU. Only vertex transform, and fragment operations, are done by graphics hardware.

Second, what you describe is very similar to what stencil shadows do, except the stencil shadows work for objects that move, i e, they “recompute” for free for each frame.

I am trying to do something similar, but to get it cost-efficient, unless you can precompute, you have to simplify the geometry alot and make as much approximations as possible. Think of the shadow volume as a ‘diffuse’ object rather than a perfect projection.

As previously said, trying to get sharp correct shadowing from arbitrary objects moving around alot, its better to try stencil-shadowing instead. Although I have problems getting the attenuation of these shadows correct.

You get attennuation with stencil shadows by doing one pass per light.

Simply accumulate contribution from all different lights into the frame buffer, one at a time. Don’t accumulate a light, if the fragment is in stencil shadow. Getting the attennuation right is the same as getting the attennuation right with no stencil shadows at all.

Ah, thnx.

I’m trying to shy away from stencil shadows. I need to think of the shadow as a volume so you can see it’s geometry when it intersects a dynamic translucent volume like billowing smoke, stewing fog or flowing liquid.

the entire heirarchy of objects is done in a binary tree which tests the intersection of the view volume in decreasing quadrent sizes tossing out the one’s which dont and keeping the one’s that do. depending on the size of an objects 2d perspective projection determines for which objects higher degrees of detail can be computed.

there lies a dichotomy between the depth of the tree (the number of objects shown), which objects get more deapth than others, and what effects should be completed for what objects.

worst case on a slow computer it could ignore everything but the geometry and rudimentary lighting. if the frame rate and deapth into heirarchry of objects meet minimum requirements more passes over the tree will be carried out adding details like shadows and reflections to the objects which have the larger 2d projection.

so I might be able to get a couple shadows out of my algorithm but I don’t expect every blade of friggen grass on the ground to project a volumetric shadow. the most important computations for me are the physics operations which will be implemented in the same object tree that the graphics engine uses. although I want the ability to crank up the graphics on higher end systems.
its taking me way to long trying to work on it myself. but I have all the algorithms worked out.
-Collin

If you want to do shadows in billowing smoke, shadow maps (depth or, possibly, ID maps) seem to work pretty well. Unless you need partial occlusion from the smoke itself, but that’s kind-of hard to do real-time.

The almost-real-time solution I know of involves sorting things by distance-from-light, and rendering each object in turn to the framebuffer, and to a shadowing texture to be applied to the next object.