Sign in to follow this  
karx11erx

reflect() function for normal and light vector?

Recommended Posts

I have to admit my knowledge of vector math is very limited indeed. :) How do I compute the reflection vector if I have an 'incoming' vector v and a surface normal n of the reflecting surface please? is it "2 * n * (n dot v) - v"?

Share this post


Link to post
Share on other sites
edit:
-2.0f * n * (n*normalize(v)) + v

where n is the surface normal and v is the direction vector you want to reflect

since you aren't normalizeing v i think you're over estimateing the projection of v onto n which would fuck up your results.

Share this post


Link to post
Share on other sites
Quote:
Original post by Darkstrike
v-2*n*(n.v) is correct as long as n is normalized. If it isn't, v - 2*n*(n.v)/(n.n) is the way to go. v doesn't need to be normalized in either case.


quoted for truth.

sorry, i didn't think before posting.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this