1
votes

I am doing ray tracing and I do the refraction of the ray using the following relation (I got it from PDF called "Reflections and Refractions in Ray Tracing"):

enter image description here

enter image description here

But I have seen it in another PDF as follows:enter image description here

Could you please explain for me why?

And how can I reassure that my refraction vector that I calculated is correct?

Thanks

2
This has nothing to do with designing, writing or debugging code, language details, or anything else normally found on this site. For optics, try physics.stackexchange.com but even there, your question is likely to be closed, since you don't seem to have a real question. What's the point of the second set of equations - those look the same as the first in a casual glance. - DarenW
The difference is the sign and it is ray tracing question so the people here know what's going on. - Jack_111

2 Answers

0
votes

Assuming that your vectors are actually xyz triplets:

float3 reflect( float3 i, float3 n )
{
  return i - 2.0 * n * dot(n,i);
}
0
votes

There's a decidated (and nicely written!) introductory chapter to reflection and refraction formulas in the latest "Ray Tracing Gems 2" book; available for free on https://link.springer.com/book/10.1007/978-1-4842-7185-8 - see Chapter 8, by Eric Haines.