What Shadowing techinque should I use?

Started by
28 comments, last by duhroach 19 years, 7 months ago
I have per pixel lighting up and running on my terrain. I want to add shadows, and not sure what method to use with per pixel lighting? I have the light position moving around in circle to simulate the sun. So the lighting is dynamic and the shadows would need to be also? I have looked at horizon mapping. Not sure if that will work or not? Thanks
Advertisement
Well, in your situation you're basically left with two possibilities: shadow volumes (stencil shadows) or shadow maps. I'm a big fan of the latter, so I'd obviously recommend shadow maps. But shadow volumes might also be an option to consider. It primarily depends on the type of geometry you use (size, face count, detail level) and on the type of shader effects you're applying to it.

I'd suggest researching both methods, and trying out both. Then you'll quickly discover the advantages and drawbacks of each one, applied to your specific situation.
Terrain would mean lots and lots of polys, I assume, so I don't think a stencil based approach would be a good idea. Edge finding and such would probably take a very long time.

Shadow maps are probably much more efficient...but I believe they don't work with point lights, and it sounds like that's what you're using.


I don't have real suggestions, unfortunately, but it doesn't seem to me like either of Yann's ideas are feasible. But I could be wrong; disagreeing with Yann is usually not a good idea [grin]
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Quote:Original post by Promit
Terrain would mean lots and lots of polys, I assume, so I don't think a stencil based approach would be a good idea. Edge finding and such would probably take a very long time.

Depends. That's generally not the bottleneck (much can be either precomputed, or done on the GPU), but fillrate might very well be. Shadow maps will most likely be much more efficient. But it really depends on the situation.

Quote:Original post by Promit
Shadow maps are probably much more efficient...but I believe they don't work with point lights, and it sounds like that's what you're using.

SMs work with pretty much every type of light source you can imagine: point lights, spot lights, directional lights, in a modified form even area lights. The sun is best modelled as a directional light, btw, which makes it even easier due to the orthographic projection.

Quote:Original post by Promit
I don't have real suggestions, unfortunately, but it doesn't seem to me like either of Yann's ideas are feasible. But I could be wrong; disagreeing with Yann is usually not a good idea [grin]

Heh, feel free :)

But shadowmaps are very feasable on large and complex geometry, in fact, that's one of their strong points. You might need some form of advanced shadow mapping algorithm though (PSM, TSM, LSSM, etc). But it really depends on the scale and precision you want/need, so Mars needs to be a little more precise about his requirements.
Well, if shadow maps work with point lighting, that should be perfect. I know they work with directional...he mentioned moving the sun, so I assumed it was point, but I suppose it could simply be a rotating directional.


I wouldn't want to use stencil shadows on terrain though. Lots of polys to find edges with, extra passes to be done, the shadow hull probably won't be simple, etc.


So best thing to do is probably to research one of the shadow mapping algorithms Yann mentioned.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Quote:Original post by Promit
Well, if shadow maps work with point lighting, that should be perfect.

Yes, point light shadow mapping is usually achieved by using either a cubemap or a dual paraboloid map instead of the common 2D depth texture. The map generation is a little slower, but it works pretty well in practice (you don't need to regenerate the shadowmap every frame either).

Quote:Original post by Promit
I know they work with directional...he mentioned moving the sun, so I assumed it was point, but I suppose it could simply be a rotating directional.

Rotating directional is best for sunlight. It takes less resources than a point light, and gives you much more precision (since perspective depth aliasing, a common problem with SM, doesn't apply to orthographic projections).
Yann -- please don't leave again, ever [grin]
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
I -will- give you chocolate cookies if you stay! [grin]
I will if he makes it to Bath on his travels... [wink]
If at first you don't succeed, redefine success.
I second the opinion that shadowmaps would be a good choice in this situation. And, like Yann said, you can even avoid problems like depth perspective aliasing if you represent the sun as a directional light source, (which is what makes most sense anyway).

Still, shadowmaps aren't perfect. Most articles on the subject will also present you with the downsides of the algorithm as well. One of them is the dueling frusta problem. Which is in a situation where the camera is oriented towards the light-source, and you get blocky edges in the shadowmap. Does anyone know if this will be a big problem in a terrain-rendering situation like this?
I also imagine you'd need a pretty high-resolution shadowmap, for a light covering an area as big as that...

This topic is closed to new replies.

Advertisement