# Confusion in generating shadow volumes

This topic is 4484 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 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.

1. 1
2. 2
Rutin
21
3. 3
4. 4
A4L
15
5. 5
khawk
14

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633737
• Total Posts
3013612
×