Jump to content
  • Advertisement
Sign in to follow this  

Question about casting 2D shadows on 2D walls

This topic is 3721 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 all, after seeing screens of O-San's awesome isometric mapping I decided this forum would probably be my best bet to find an answer to my quandary :P I'm working on a simple little 2D tile engine in c with OpenGL, with some extra goodies, one of which is dynamic lighting. Here's a shot of what I have now: and here's a render of just the lights: The method I'm using to cast shadows on the floor is an optimized/extended version of that found in this article, which I'm sure a lot of you have seen :) Basically, shadows are projected from the light to boundary points in convex "shadow regions" and then stenciled out. The "wall" tiles are lit according to a normal that is stored with each tile in the map, pretty simple stuff. However, notice how the shadows on the floor don't interact with the normal-lit tiles (for example the small wall is still lit by the green light in spite of being totally covered by a shadow). I'd really like to add this if there's an efficient way to do so, and I could use a kick in the right direction, or maybe just the opinions of a few coders with more experience than I. Ideas I've toyed with: 1) Since the shadows are projected out from one edge (see second shot) I can check to see if the vector from the light to any given tile intersects one of those shadow base edges... not really accurate but might be good for trivial rejection? If a tile "straddles" a shadow edge I can handle that as a special case. 2) By the time the actual geometry for the light is rendered the stencil buffer contains values that mask out the shadow umbra, penumbra, and unshadowed areas. I haven't experimented with it yet but it's possible to copy that stencil buffer and then check its values where the tiles fall. The downside to this is that I can't really detect angle of the shadow this way and that would totally suck for tiles that don't have a normal pointing straight down on the y axis. Any input would be appreciated. Sorry if I didn't give enough background information, I'll clarify anything if need be. Thanks in advance! -Mason edit: totally forgot the article link :P [Edited by - sg on May 15, 2008 6:41:13 AM]

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!