Archived

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

Dynamically generated sprite shadows

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

I''m writing an old-skool sprite-based game where the player''s sprite (yeah, textured quad) casts a shadow onto a tiled midground (and maybe other sprites if I can make it fast enough). However, there are gaps in the midground image where I don''t want this shadow to appear where it would be on the background image. I''ve been trying to do this by combining the alpha of the player''s sprite with the alpha of the tiles covered by the shadow on the fly, and so far I can get a image of the shadow which I can grab to make a texture, which is then applied to a quad to draw the shadow. How can I turn this grey image into an alpha channel representation (grey = 50% alpha, black = 0 alpha), so drawing in black would darken the shadowed area accordingly, or should I use some other method? All the shadow tutorials are about 3D objects so are no use to me.

Share this post


Link to post
Share on other sites
No takers on this...?

Well anyway, I managed to get the effect I wanted by using the stencil buffer, just didn''t use it before as I couldn''t get it working right at first, none of that faffing around with drawing anything offscreen first either!

Share this post


Link to post
Share on other sites