Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to implement a dynamic shadow system for a 2d game using this tutorial :

but I am stuck at the point where I need to determine which face is front facing or back facing the light source.


Is there a simple technique to apply in order to find out which face is in front and which one is in back?

share|improve this question
up vote 2 down vote accepted

The dot product of the each face's normal with the vector from the face to the light position should distinguish which faces are front/back.

share|improve this answer
Thank you but can you be more explicit? For a square shape, I will have four vector from the light to each points of the shape. Which light vector may I test with which normal vector from the face? For example a square ABCD and light source L, may I do normal(AB).dot(LA) or normal(AB).dot(LB)? – Alexandre GUIDET Apr 24 '13 at 12:24
dot producting with either will suffice I think. Heres a visual of the idea if that helps: picture – Biggy Smith Apr 24 '13 at 13:38
thank you very much, I understand thanks to your picture – Alexandre GUIDET Apr 24 '13 at 13:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.