Refraction Vector (Ray tracing)

2019-06-04 20:34发布

问题:

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"):

But I have seen it in another PDF as follows:

Could you please explain for me why?

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

Thanks

回答1:

Assuming that your vectors are actually xyz triplets:

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