Sign in to follow this  

simple shadow volume generation

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Well I'm trying to understand the theory behind shadow volumes and at least for me find understanding things a lot easier when I can visually conceptualize what happening. Naturally, I drew a picture detailing what I think would be a way to generate shadow volumes and I was wondering if it seemed correct, and if so if there are any shortfalls to my method besides being slow for huge scenes. This technique would be done for each every single triangle drawn, but I do not think it would be too unfeasible in my case since my models are very low poly and the scenes in my game probably average to about 500-1000 polygons. Here is the picture: http://studentweb.tulane.edu/~mconway/shadow_volume_generation.GIF

Share this post


Link to post
Share on other sites
That's a novel approach, but it would be incredibly slow, since it's O(n^2) in the number of triangles (so the time to render a frame will increase exponentially with the number of triangles). Also, it wouldn't be able to take advantage of hardware acceleration properly.

The usual shadow volumes algorithm involves finding the silhouette edge of an entire mesh from the POV of the light, and then generating the volume by extruding the silhouette. When rendering the scene, you can generate shadows by using the stencil and Z buffers to find which fragments (pixels) are inside the shadow volume; this part is done entirely in hardware. Read up on it anyway.

You might also want to take a look at shadow mapping while you're at it.

Share this post


Link to post
Share on other sites
Well I assume this would still be applicable for scenes which have 500-1000 polys (my levels are relatively simple)? In fact most of my geometry is composed of spheres and cubes, so I could code algorithms to compute shadow volumes specifically for them to reduce much of the overhead.

Also, I currently am not using lighting for my scenes (just unlighted textures), will I be required to have lighting in order to produce blended shadows with stencil volumes?

Share this post


Link to post
Share on other sites
Quote:
Original post by Khaos Dragon
Well I assume this would still be applicable for scenes which have 500-1000 polys (my levels are relatively simple)? In fact most of my geometry is composed of spheres and cubes, so I could code algorithms to compute shadow volumes specifically for them to reduce much of the overhead.

You could try if you want to, but I doubt your algorithm would be efficient enough for real-time rendering.

Quote:
Also, I currently am not using lighting for my scenes (just unlighted textures), will I be required to have lighting in order to produce blended shadows with stencil volumes?

Well the best approach would be to render the unlit scene, then render the unshadowed areas (where the stencil value is zero) for each light, adding in each light's contribution with additive (glBlendFunc(GL_ONE, GL_ONE)) blending.

However, there's nothing to stop you just rendering the scene as you are now, then blending in shadows in the shadowed areas (where the stencil value is nonzero). It's a pretty flexible system really.

Share this post


Link to post
Share on other sites
I think I may try doing this at first in order to implement the algorithms, and then work on a silhoutte method, however by doing this my shadow volumes will not be completely hollow since lots of shadow volumes will overlap each other in the same place. Would this cause major precision errors?

Share this post


Link to post
Share on other sites
Aside from anything else, the fill rate demands with your method would be obscene. Seriously, don't do it. Silhouette finding is actually really simple and can be done in linear time (in the number of triangles).

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

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