Mathematical formula of Vector Refraction?

Thank you for the explanation!
Sorry for late reply. I was at school.


What do you think?

Sorry, I don’t think I can provide anything useful as I’m inferior in these subjects compared to you. I’m currently talking to a Physicist, I will tell you anything that I find useful after talking to him.


So I have to 2 formulas:
t = (n(ni)−i)nᵢ/nₜ−n√(1−(1−(ni)²)(nᵢ/nₜ)²)
t = (in(ni))nᵢ/nₜ−n√(1−(1−(ni)²)(nᵢ/nₜ)²)

I don’t think I’m gonna use first one since it’s not OpenGL’s formula (which is what I’m told to be what Blender implemented as Vector Refraction), even though it outputs correct refracted vector. And the second one is what I transcribed from OpenGL’s code so I’m gonna use it.

Another reason I’m avoiding it is because its direction of the incident vector is not theoretically correct (as you said, in Physics, the incident vector is supposed to point inwards, but here, its incident vector is derived to point outwards).

Also, its in and tn has different signs (whereas my latest calculation uses OpenGL’s formula which outputs same sign for both in and tn. Why should I care? Because tn should always have the same sign as in, as refraction doesn’t change the direction (whereas for reflection, nr should always have the opposite sign to in).


Here are the derivations of the first formula, hope you’ll find them useful, you can see that in all the diagrams of these derivations, i is derived to point outwards:

  1. Slidetodoc.com (Derivation appears after clicking “next” 35 times)
  2. Ohio state edu (At slide 12)
  3. Stack Exchange (Images in the replies - it’s from a book)

I can’t find any derivation of the second one (OpenGL), apparently no one has ever derived it.


the formula is meaningless if the normal and incident vector have the same “overall direction”

Does it mean that my second calculation here doesn’t serve any purpose? Does it mean that, as long as ni ≤ 0 , the function has a chance to output correct refracted vector and ni > 0 will output incorrect vector?



I notice that, the side of the box whose incident vectors have opposite “overall direction” to the normal vector get refracted and outputted like that. But the side of the box whose incident vectors have the same “overall direction” to the normal vector just disappears. Actually those vectors don’t disappear but are overlaying the refracted vector, like this:
success3
What do you think?


I’ll ask the blender devs as well

Yes sir. Do as you please.

2 Likes