Archived

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

shadow casting in 2d RTS

This topic is 5380 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, i have a question, i don''t know if i placed it in the right forum, so pls excuse me if i didn''t, anyway i''m writing a 2d RTS and i''d like to add shadows to buildings, units, etc. I know i could use pre-rendered images and alphablend them but i saw that there are games that generates shadows realtime, or at least generates them at load time. I was wondering if anyone could point me to a tutorial or give me some hints saying that shadow is casted in the north-west part of the object. thnk u

Share this post


Link to post
Share on other sites
how about Hostile Encounter? www.hostileencounter.com and there are more...and i read about some saying that shadows are real-time casted and were pure 2d.

Share this post


Link to post
Share on other sites
I suppose they could use the 2d sprite and project a shadow texture from it... not exactly sure why you would want to (i mean, if the game can handle dynamic lighting and shadowing, why not use 3d models...)

Share this post


Link to post
Share on other sites
ahm...the game does not suport dynamic lightning or shadows...i just don''t want to render the shadows for each building and i thought that there could be a way of generating shadows at load-time by modifying in some way the sprites or their transparency mask

Share this post


Link to post
Share on other sites
The link you posted earlier for Hostile Encounter uses a very simple technique of making a black mask of the image (black for opaque areas, and transparent areas are left transparent), and then just drops the shadow about 12-16 pixels north and west of the sprite prior to rendering the sprite itself.

They didn''t distort the image in any way before turning it into a shadow mask. If you are doing your game using your own software blitter routines, then just make a sprite blitter that looks something like this:

for(every pixel in sprite)
if(pixel != transparent)
dest = dest / 2;
end if
end for

... Where ''transparent'' is your transparent color key value. Bingo. You''ll now have shadows that look just like those in Hostile Encounter!

- Air

Share this post


Link to post
Share on other sites