I am about to create a Jump'n'run game using Box2D for the physics. I am asked to add a Dropshadow to the main Character, but as I noticed this could become quite complicated. Basically the Light should be parallel with an angle of 90°, so from top to bottom. Please see the image below.


I would like to Ray Cast the upper left and upper right edge of the characters AABB downwards to the ground and find the lines marked in Red.

Right now I have good Idea, I just thought to use a whole bunch of Rays, but this might become a performance bottleneck and is not that precise anyway.

How could I solve the »Shadow-Problem« properly?

Thanks in ahead!


As asked in the comment, here some additional notes.

The angular line at the bottom is meant to be the ground and the rectangle just below the character represents a platform. These are the shapes which should receive the shadow. The light should go from top to bottom, like raindrops falling down if no wind is present. So the extends of the AABB in x-direction represent the left and right region which should create the shadow, or, in other words, the width of the shadow.

  • \$\begingroup\$ I guess that by “the Light should be parallel with an angle of 90°” you mean the light is directional from above, not that the light is parallel and orthogonal at the same time as I firstly understood... Also, comment a bit more your picture please. What is the angular line below ? Why shouldn't the left part of your ellipses cast shadows ? \$\endgroup\$ – Lærne Apr 4 '14 at 9:16
  • \$\begingroup\$ please see the edit… \$\endgroup\$ – philipp Apr 4 '14 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.