Refraction Vector (Ray tracing)
Asked Answered
B

3

1

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

Broome answered 23/10, 2013 at 17:25 Comment(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.Boatright
The difference is the sign and it is ray tracing question so the people here know what's going on.Broome
L
0

Assuming that your vectors are actually xyz triplets:

float3 reflect( float3 i, float3 n )
{
  return i - 2.0 * n * dot(n,i);
}
Lyle answered 28/11, 2013 at 6:56 Comment(0)
C
0

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.

Content answered 7/9, 2021 at 19:12 Comment(0)
G
0

If you do the derivation yourself according the figure, where we have surface normal pointing in the opposite direction (dot product of incident ray and normal is negative), I think it is safe to say the front ones are correct. For the latter ones, it seems that the normal is flipped to the opposite side of the surface yet we calculate all the cosine terms w.r.t the new normal vector. So in this situation (notice that cos theta_i is negative now, w.r.t to the downward-pointing normal, we can substitute it by -cos(pi - theta_i)), we can actually get the equivalent formula in which the only difference is one more negative sign for the normal vector. So I think the contradiction is caused by the direction of the normal vector and the definition of incident angle.

Germanous answered 6/2, 2023 at 17:11 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.