Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

http://www.gamedev.net/page/reference/index.html/_/technical/graphics-programming-and-theory/dynamic-2d-soft-shadows-r2032

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

light-vector-projection

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

1 Answer 1

up vote 1 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

 
discard

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.