Archived

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

ktw6675

the best approach to 2D shadows?

Recommended Posts

ktw6675    122
My smooth scrolling OpenGL sidescroller ( http://www.cs.rit.edu/~ktw6675 ) is up and running nicely with multiple tile layers at 60FPS, but now I'm looking for that extra layer of graphical goodness that might really make it stand out. Take a look at this screenshot from another sidescroller, "Gish." http://www.cs.rit.edu/~ktw6675/imgs/gishscreen.jpg I was impressed with the way Gish's engine handled shadows--yeah they are "hard" shadows but they are completely dynamic and since I'll be having lots of movable objects in my game I thought it'd be worth it to try and implement a similar system. Unfortunately I haven't really gotten my hands dirty with OpenGL yet--I'm using a library that lets me draw and manipulate 2D openGL objects without actual OpenGL calls. I can still use those calls, though, so that's why I'm asking you guys...how are those shadow polygons calculated? By the way you can find the Gish demo at http://www.chroniclogic.com/index.htm?gish.htm [edited by - ktw6675 on May 26, 2004 6:48:29 PM]

Share this post


Link to post
Share on other sites
weyland    122
You need to mathmatically "draw a line" from the lightsource to the corners of your objects and cast that onto the "walls", but since you are using sprites I''d look into projected textures ...

Share this post


Link to post
Share on other sites
OrangyTang    1298
You''re in luck, I just happend to write an article a little while ago that covered this kind of shadows.

Hard shadows like Gish are relativly easy, and can be done using the stencil buffer if you''d rather leave your alpha buffer untouched. Soft shadows take somewhat more work, but are worth it.

Share this post


Link to post
Share on other sites
ktw6675    122
Thanks! That looks exactly like what I had imagined. It''s still a little over my head as far as OpenGL knowledge goes, so I have some reading to do, but it should be a huge help.

Share this post


Link to post
Share on other sites