Sign in to follow this  
Chordogg

Confusion in generating shadow volumes

Recommended Posts

I understand the process for generating a shadow volume. Find all the silhoutte edges of an "object" and extrude those. But what if the object you want to create a shadow volume for is a complete level in a game? Right now my levels are just polygon soups. How do I calculate a shadow volume for that? Or maybe I'm not thinking of this in the right way...Don't the objects have to be convex? Say there's a room...4 walls a ceiling and a floor. Then you have a box in the center suspended in the room and a light right above the box. The light should generate a shadow on the floor. But when the algorithm goes to search for silhoutte edges, it'll search for edges in the box in the room, and the edges in the room itself. That can't be correct can it? How do I make it so the level generates shadows onto itself. Thanks!

Share this post


Link to post
Share on other sites
The object does not have to be convex, but the shadow volume you create has to be closed. In addition, it helps greatly if your mesh is an open manifold (i e, each edge is shared by at most two triangles).

To create shadow volumes for your level, I would suggest keeping an adjacency list parallel to your triangle index list. For each triangle, store the index of the triangles that neighbor that triangle along each edge. When generating silhouettes, you can use this information to do neighbor walks until you find a triangle that's facing away from the light, or that is outside of the light frustum. You then need the outside edges of these connected patches of triangles.

If you have triangle soup, you probably want to pre-process to generate this adjacency information (and weld very close verts to a coincident location).

Share this post


Link to post
Share on other sites
Sounds like a really good idea thanks! I think that would work really well for static lights that don't move so I can just precalculate the shadow volumes. I'm wondering how to make this run fast with lights that move. I like the neighbor walk idea, I'll have to try that out.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this