Jump to content
  • Advertisement
Sign in to follow this  
GremlinX

Shadowing using ShadowVolumes or ShadowMaps

This topic is 4848 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

Hi, I am fairly new to doing shadowing in Direct3D. I am looking at the 9.0c SDK samples called ShadowVolume and ShadowMap. The ShadowMap sample looks better suited for what I need, but it requires PS2.0, and I want my project to run on PS1.1 cards. The ShadowVolume sample requires PS1.1, but it looks like I need to render the scene 2 times for each object that I need to create a shadow for - is this correct? I haven't found a way to successfully batch the shadowing process using the Volume demo. Does anyone have any thoughts on which technique is better/faster and where I can get some samples/tutorials that outline how to do this using PS1.1? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Both algorithms can be good for different applications.

Since you want a PS1.1 (or below) algorithm, go for shadow volumes, that's DX8 (DX7?) based technology. In fact, SVs are good for almost any non-next-gen solution, as, for example, Doom3 demonstrates. Plus, SVs produce a far higher quality shadow than SMs, aside from the fact that it's hard shadowing and not soft.

I'd say though, that if you were doing any next-gen engines, do SMs without looking back.


Oh, if you do go with SVs, do realize that an increase in poly count hurts performance quite a bit.

Share this post


Link to post
Share on other sites
Shadow volumes sound like the way to go for my needs then. 1 more question. In the DX9 SDK sample called "ShadowVolume", they use the dwarf mesh and cast a shadow on the environment. In order to accomplish this however, they set the effetc state to "ambient", render everything, clear the stencil buffer and render everything again. Is it neccesary to always render everything 2 times? Also, if I want to have shadows coming off more than 1 object, can I use the same effect interface for all the objects, or does each object need it's own effect?

Thanks for your help!

Share this post


Link to post
Share on other sites
Rendering requires at least 3 passes. The first is a z pass, but if you really want to cut down on passes, this could also be your color pass. After you've filled the z-buffer with all values (render the entire scene with z buffering), you run a shadow pass, which fills the stencil buffer according to a (precalculated) volume. Next, you run a full-screen quad (I used D3DXSprite) with a darkening effect according to a stencil test. Another option would be to have the final quad a color pass, using the generated stencil value for more accurate shadow colors.

It is quite a performance eater, especially the PS. Large volumes cause a significant drop in fps, though I've got an FX5200, which isn't known for it's pixel proccessing power.

Also, I used that sample's degenrate triangle creation code, and it worked quite okay :).

Share this post


Link to post
Share on other sites
Thanks for the tips sirob. I have 2 questions for you:

1. "Rendering requires at least 3 passes" - does this mean 3 passes per object, or 3 passes in total for everything that casts a shadow? If it is 3 passes total for all objects, do I need a seperate Effect instance for each object, or can they all share 1?

2. "I used that sample's degenrate triangle creation code" - What do you mean by this?

Share this post


Link to post
Share on other sites
Your passes typically go like this:
An ambient pass, which you just do once to make things in shadow not totally pitch-black (if you want). Tthen you do 2 passes per light, one to draw the shadow volumes for that light into the stencil and the next to actually do the scene lighting for that light. I think that's right.

-Mezz

Share this post


Link to post
Share on other sites
Do I need a seperate effect instance for each object in the scene, or just 1 effect instance? Also, is that 3 passes per object (so 5 objects would be 15 passes) or is that 3 passes in total?

Thanks

Share this post


Link to post
Share on other sites
The total passes sums out to something like this:

1 x entire scene + 1 x everything that casts a shadow (these were also in the first rendering of the entire scene) + 1 x fullscreen quad.

In reality, what you're drawing OVER what you'd normally draw is each shadow caster and a full-screen quad.

Regarding degenerate triangles, this is a part of creating the shadow volume. I'd suggest you have a look at a few tutorials and maybe the DX sample, and see exactly what's going on, since this would take too long to explain here.

Share this post


Link to post
Share on other sites
Thanks for all the help guys - it's working perfectly now. Just 1 more question regarding this. I can't seem to get specular lighting working since I started using this effect. Even if I enable it right before I call the DrawSubset, my mesh still doesn't render out "shiny" like it used to. Am I missing something?

Thanks

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!