Jump to content
  • Advertisement
Sign in to follow this  
supagu

refrection of a vector

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

so, heres my reference page: http://en.wikipedia.org/wiki/Snell's_law so i do incidence vector dot normal and get: -0.019998666 then i do: float cosRefraction = sqrt(1.0f - (refractionIdx * refractionIdx) * (1.0f - cosIncidence * cosIncidence)); but: 1.0f - (refractionIdx * refractionIdx) * (1.0f - cosIncidence * cosIncidence) comes out as a negative number! refractionIdx = 1.33 (which is the refraction idx of water) vector is pointing in to the water, the normal is pointing up from the waters surface. have i got the equation wrong?

Share this post


Link to post
Share on other sites
Advertisement
I think u'd better use this instead to obtain the same result.

RefractedAngle = asin( ( air_r_index * sin(IncidentAngle) ) / water_r_index );
CosRefractedAngle = cos( PI*RefractedAngle/180);

Share this post


Link to post
Share on other sites
Looking at the image, the ray comes from a medium with n1 and goes into a medium with n2. The author says that n1 < n2, i.e. this could be air to water refraction.

So n1/n2 should be 0,77 and not 1,3.

What you calculated was that total reflection works ;-)

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!