View Full Version : Stencil shadows for whole scene?
Phaetos
01-03-2007, 12:34 AM
Hi!
I have an empty map wird decorating items as separate meshes in it (e.g. trees, houses, stones, etc.). Now I'd like them all to cast shadows. My implementation of stencil shadows is finished and working fine already for the player and enemy characters - but I'm not sure whether I should use the stencil shadows for the decorating items in the map, too?
The shadow volumes are precalculated and stored for usage in the render process. I am rendering all shadow volumes at once for a scene (First render all front facing polys of all shadow volumes, then render all back facing polys of all volumes, and then draw all shadows).
Would this be a suitable solution? Or should I better use a hybrid approach: Shadow maps for the static shadows and stencil shadows for the animated characters?
Whats your experience with this?
Thanks
Stefan
Reedbeta
01-03-2007, 12:51 AM
Stencil shadows take a lot of fillrate. If you like the sharp-edged look of stencil shadows, one thing you could consider doing is pre-tesselating the level geometry according to the shadow volumes of the static objects. This would probably improve run-time performance at the cost of needing some pre-processing. It would be like lightmapping but at the geometry level instead of using textures.
On the other hand, using shadow mapping would definitely be a performance win since you'd only have to render the depth map once for the static objects, and it would be a lot easier to implement. On the other hand, it produces fuzzy edges (which isn't necessarily bad) and can look crappy without careful attention to filtering (which is also a slowdown). Depending on the kind of scenes you have, you might also have to deal with things like perspective shadow maps.
SpreeTree
01-03-2007, 01:01 AM
Im most cases, there doesn't seem to be much point in using stencil shadows for objects that do not move.
Tree's (unless they rock in the wind), rocks, buildsing etc. all have static shadows and shadow maps should suit you perfectly - unless you want dynamic light sources, day/night cycles etc. ;)
What Reedbeta says about care being taken on the look of the shadow maps should be taken to heart. If you want the shadow maps to look good, you might end up using very high res textures, in which case you might end up with to high a fill-rate anyway!
It all depends on the stype fo scene you are going for, and what you want the final look to be. The best bet would be to reserach the different types of shadowing techniques available (and there are quite a few), and pick which ones are the best for each different aspect of your scene :)
Spree
Phaetos
01-03-2007, 04:14 AM
Hi!
Thank you for your tips! I think I will try out shadow mapping as tesselation sounds difficult to implement and the shadow mapping algorithm is kind of a standard.
BTW: I found a nice tutorial on shadow mapping: http://www.paulsprojects.net/tutorials/smt/smt.html
Thanks again for your help!
Stefan
.oisyn
01-03-2007, 04:52 AM
Also don't forget that stencil shadows only work for opaque and closed solid geometry. If you have, say, an iron fence modeled with alpha tested polygons, the bars won't show up in the shadows. This is usually also the case for trees and plants where the leafs are modeled using a bunch of alpha tested polygons.
All these downsides made most developers drop stencil shadows altogether. As did we.
SpreeTree
01-03-2007, 11:40 AM
All these downsides made most developers drop stencil shadows altogether. As did we.
We used stencil shadows for the main characters on the last project I worked on, and it was a nightmare getting them to look correct - in fact I think we got it working the day before master.
So I agree with that ;)
Spree
TheNut
01-03-2007, 12:33 PM
For static environments you should consider some kind of radiosity generator. This will provide the most realistic looking graphics and fastest performance. There's a few 3D modeling packages out there that can do this for you. On the dynamic front, it's a coin flip. The standard stencil shadow algorithm is coarse looking, but supports omni directional lights (see: soft stencil shadows). There are some techniques out there to soften it up and the results look very impressive. Shadow maps require special hardware, but can look very nice (see Silent Hill series). Since you already have a shadow volume system, I would suggest continue using that unless there's something preventing you from doing so, otherwise consider radiosity maps for your environment.
Phaetos
01-04-2007, 01:43 AM
@.oisyn: The design will be a comic-like look, so I don't have to use much details - therefore there is (yet) no need for transparent textures :) But thanks for pointing that out - I wasn't aware of this limitation until then.
If you left the path of stencil shadows - what else do you use to let animated actors cast shadows? - just curious.
@SpreeTree: In my game I only have third person perspective and the scene is illuminated by a sun staying at some hours past noon - so the shadows are small and I only have a few animated meshes. I'll stick to stencil shadows for the actors, too.
@TheNut: Do you mean "light maps" when you talk about "radiosity maps"? Radiosity is, as far as I know, a technology to simulate realistic ambient light distribution in a scene. The results of this calculation is a detailed ambient distribution, but no shadows?!
Can you detail that a little bit?
Thanks!
Stefan
.oisyn
01-04-2007, 02:35 AM
If you left the path of stencil shadows - what else do you use to let animated actors cast shadows? - just curious.
We use shadow maps for everything (shadow maps as in: render depth values of the scene from the viewpoint of the light, project the map on the geometry and use distance testing to test whether a pixel falls in the shadow)
These also have issues (mostly accuracy issues, and you have to render 6 maps for omnidirectional lights), but they are much more flexible than stencil shadows.
Reedbeta
01-04-2007, 03:03 AM
Do you mean "light maps" when you talk about "radiosity maps"? Radiosity is, as far as I know, a technology to simulate realistic ambient light distribution in a scene. The results of this calculation is a detailed ambient distribution, but no shadows?!
Radiosity is the technique that would produce the light maps. And the light maps would include shadows cast by static objects, as that's part of the "detailed ambient light distribution"! (Actually it includes diffuse light distribution from static light sources to static objects as well, but not specular unless you use an extended version of lightmaps that also include the direction of incoming light.)
vBulletin, Copyright ©2000-2010, Jelsoft Enterprises Ltd.