Jump to content
  • Advertisement
Sign in to follow this  

Shadow Volume for flocks

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

Greetings, We are programming our game and got a problem with the shadows (you may see the problem in the screenshots at www.warscale.com). Originally we were using a Shadow Volume algorithm, but we found that shadow volumes won't work with small details like tree leaves. As you know, it's common to use textured planes for the tree leaves. You place many planes so the tree looks full. The problem is that the shadow volume is not designed for planes so we ended with really ugly shadows. So we switched to shadow maps. We are using a 512x512 shadowmap but when the camera comes close to the unit the shadow looks truly bad. We were thinking raising the shadow size to 1024x1024. That may solve the problem but many artifacts appear in some video cards and the algorithm becomes slower. Now, I like shadow volumes, I feel them a more natural solution than shadow maps and with DX9 double sided stencil we can save a lot of time. So I wanted to try a solution for the tree leaves. How to simulate leaves using shadow volumes... I was looking at some trees in a park trying to understand the problem. Even when the trees has many leaves, the leaves form a general shape 'shape'. Some are circular, some are conical (like a pine). Some form oval patches. So take the case of a tree with an avarage spherical shape. I found this idea but need some help finishing it, maybe you can help me. Previous: Render the scene only to fill the z buffer (standar step). Pass 1 a. Set a leaf pattern texture. The pattern may be a white texture but it must have an alpha channel with a value of 0 in order to hide the unwanted portions and 255 to the areas you want to show the pattern. b. Set an alpha test in order to reject the portions with alpha = 0. Pattern used is left to each case. c. Set color and z write to false. d. Render the FRONT faces increasing the stencil where any pixel passes the alpha test. Pass 2 a. Render the back faces of the shadow volume. As usual decrease the stencil but using D3DSTENCILOP_DECRSAT instead of D3DSTENCILOP_DECR. DECRSAT clamps the minimum value to 0 meaning that even in the case that we might reach -1 in the stencil, we clamp it to 0. When this is finished I think I will get a pattern in the stencil buffer, good enough to fool the eye. I haven't tested it as I'm currently away from my development PC but maybe some of you more experienced can tell me about any flaws in this approach. Maybe we can use this same approach for rendering some objects like flocks (instead of rendering each independent bird, fish or insect), sand storms (for earth/sand elementals), hair shadows, wire fences... I can think about so many uses... Luck! Guimo

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!