Jump to content
  • Advertisement
Sign in to follow this  
catch

2d Shadows

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

Howdy. I'm curious if anyone has an article on 2d shadows. I mean convincing 2d shadows, not just blobs at sprite's feet. I can do direct opengl calls, and most of my game is actually opengl, but I'm using 2d sprites, not 3d geometry. Any simple way of doing this? I played with yaw/pitch/rotations and alpha blending to make a black version of my sprite and position it behind my sprites with some decent effect, but some things look right, many things don't.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by catch
Any simple way of doing this? I played with yaw/pitch/rotations and alpha blending to make a black version of my sprite and position it behind my sprites with some decent effect, but some things look right, many things don't.


Such a technique is generally never going to look very convincing.

Fundamentally, a 2D sprite is just a projection of some 3D object onto a plane; so taking that image and projecting it onto any other plane that is not parallel to the sprite's plane is almost always going to look incorrect. Specifically, shadows generated this way will always look wrong unless every point of contact between the sprite image and the ground lies in the same visual z-plane. (Since the contact points are the most visually apparent indicator of proper shadowing.)

Honestly, the best options (while still staying 2D) are to use either predrawn shadow sprites or the traditional shadow "blobs".

Share this post


Link to post
Share on other sites
Interesting. I'll have to study this in more detail (at work now).

Course if I'm using no geometry, I'm not sure how this would generate an actual shadow. Hmm, gives me something to look into, though.

Thanks!

Share this post


Link to post
Share on other sites
Quote:
Original post by Anthony Serrano
Quote:
Original post by catch
Any simple way of doing this? I played with yaw/pitch/rotations and alpha blending to make a black version of my sprite and position it behind my sprites with some decent effect, but some things look right, many things don't.


Such a technique is generally never going to look very convincing.

Fundamentally, a 2D sprite is just a projection of some 3D object onto a plane; so taking that image and projecting it onto any other plane that is not parallel to the sprite's plane is almost always going to look incorrect. Specifically, shadows generated this way will always look wrong unless every point of contact between the sprite image and the ground lies in the same visual z-plane. (Since the contact points are the most visually apparent indicator of proper shadowing.)

Honestly, the best options (while still staying 2D) are to use either predrawn shadow sprites or the traditional shadow "blobs".


Yeah I'm sort of facing that. For trees and player graphics, and relatively smaller type objects, my current rotation and pitch changes look convincing enough.

The problem is large buildings and other thicker or more square looking shapes. The projection just looks all wrong.

Share this post


Link to post
Share on other sites
You'd probably be better of skewing/scaling the sprites to create the shadows rather than rotating them. You can do it through either a matrix or by creating a quad manually that looks like a parallelogram.

Just out of curiosity, what style of 2D are you doing here? Side-scroller, top down, isometric?

Share this post


Link to post
Share on other sites
Ah yes, well right now i'm scaling them by a bit height wise, rotating them by a few degrees, and pitching them by about 60 degrees.

I wish I could post a screenshot, but I'm at work!

It's a top down style game.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!