Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

extralongpants

stencil buffer and shadow problems

This topic is 5671 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- Recently I successfully incorporated shadows (using the stencil buffer), in my engine. However, when the camera enters a shadow volume, the shadow disappears. I read a couple of articles on the subject, but neither one presented a very applicable solution. Currently, I run a test on the camera position to determine if it is in front of all the planes of all the triangles composing the shadow (with all normals pointing inward), and if it is behind all of the triangles casting the shadow. However, I do not know what to do when the test passes. If you have any ideas, or can explain to me how to render a shadow when the camera is in it’s volume, I would greatly appreciate it. I am also having trouble with the test I described earlier, as it rarely passes when it should (Although I am fairly certain the problem with that lies in the code). I would very much appreciate any help or ideas on solving this problem. Thankyou, Chris Crowe

Share this post


Link to post
Share on other sites
Advertisement
I think this article mentions how to do stencil shadows with camera being able to enter it...

The theory of stencil shadows [on gamedev]

I don''t think there''s the ''cheap'' solution you might be looking for. Stencil shadows are good, but still hw-expensive.

If this artice doesn''t help, try looking for ''carmack''s reverse'' on google.

Share this post


Link to post
Share on other sites
one thing i always wondered about is

do you have to clip any polygons or is it like that

the way i understood it is :

1st pass draw your scene from the light`s viewpoint
2nd clear depthbuffer
3rd draw the players viewpoint
4th draw a black overlay for the shadows and skip the pixels that aren t shadows


does it work that way or is there something i understood wrong


and how would you do that for directional lights?
precompiled stencil maps or how?

Share this post


Link to post
Share on other sites
Actually, i make it a little easier on myself. All my geometry is stored in world space as a default. That way, when doing calculations like shadows and bump-mapping, i don''t need to keep switching to and from object spaces. to transform an object locally, i just translate it to the origin, make transformations, and translate it back (i have found it unessecary to remember the original rotational orientation of an object). if you are using directional lights, i am assuming they are defined by a normal, pointing in a certain direction. for those lights, i would extend the shadow volume from a point P, such that P = TheCurrentVertex-TheLightsNormal. that''s my idea, anyway.
If you wanted shadow maps, i would suggest using projected texture maps, rather than stencil buffer implemented shadows.
I think you''ve got your steps a little mixed up. It seems as though you are confusing stencil shadows and projective texture shadows. I believe nehe.gamedev.net has a nice introductory tutorial on stencil shadows (that is of course, if you are using OpenGL).

Thanks for your help, Wildfire.

-Chris Crowe

Share this post


Link to post
Share on other sites
from what i have read you need to create shadow volume planes
clip the polygons against the planes and then render them

how many polys do you manage to render that way? damn thats not a very good solution

time to get a newer graphic card which supports these shadowmapping features which yann uses *GR*

Share this post


Link to post
Share on other sites

  • 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!