Vex: How to use Snell's Law for Refraction Vector?

   1031   11   0
User Avatar
Member
1007 posts
Joined: April 2017
Offline
Hi!

I came across a very informative video explaining Snell's Law. The trouble I'm having is how to solve for "r" (angle of outgoing ray). Can anybody tell me how to switch the formula around to find "r" if I have all the other values? I'm bad at math...
Edited by olivierth - Feb. 5, 2024 13:13:00

Attachments:
Houdini_SnellsLaw_01.JPG (66.3 KB)

User Avatar
Member
696 posts
Joined: March 2009
Offline
r = asin(n2 * sin(i)/n1))... me thinks
Toronto - ON
My Houdini playground [renderfarm.tumblr.com]
“As technology advances, the rendering time remains constant.”
User Avatar
Member
670 posts
Joined: Sept. 2013
Offline
https://www.sidefx.com/docs/houdini/vex/functions/refract.html [www.sidefx.com]
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
1007 posts
Joined: April 2017
Offline
What! There's already a function for that? Super!

-Olivier
User Avatar
Member
1007 posts
Joined: April 2017
Offline
Looks like the refract function works BUT, I think the surface normals have to be inverted for it to bend the rays in the logical direction...

-Olviier
Edited by olivierth - Feb. 5, 2024 17:59:58
User Avatar
Member
4516 posts
Joined: Feb. 2012
Online
You shouldn't have to invert the normals. I use the regular surface normal of a grid here to refract rays on to the floor:

Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com]

youtube.com/@pragmaticvfx | patreon.com/animatrix | animatrix2k7.gumroad.com
User Avatar
Member
1007 posts
Joined: April 2017
Offline
hmm... that's odd. we do things differently. I start with intersect to get the surface normal before I use refract.

EDIT: I'm confused. In your example, the IOR is below 1...?
Edited by olivierth - Feb. 6, 2024 12:02:00

Attachments:
Houdini_SnellsLaw_02.JPG (164.4 KB)

User Avatar
Member
7771 posts
Joined: Sept. 2011
Offline
olivierth
EDIT: I'm confused. In your example, the IOR is below 1...?

I think it's N1/N2, eg 1.0/1.5
User Avatar
Member
1007 posts
Joined: April 2017
Offline
I'm trying a simpler example and I still get weird results. My InAngle (theta 1) is 45 degrees (makes sens) but the resulting OutAngle (theta 2) is 135 when it should be less than 45. What am I not doing right? What am I not understanding?

-Olivier
Edited by olivierth - Feb. 6, 2024 13:53:16

Attachments:
Houdini_SnellsLaw_03.JPG (129.8 KB)

User Avatar
Member
7771 posts
Joined: Sept. 2011
Offline
olivierth
I'm trying a simpler example and I still get weird results. My InAngle (theta 1) is 45 degrees (makes sens) but the resulting OutAngle (theta 2) is 135 when it should be less than 45. What am I not doing right? What am I not understanding?

-Olivier

the refract function doesn't take the IOR of the medium as an argument, which you've put in as 1.6

It takes the ratio of the outside medium to the inside medium, for air and glass it would be 1.0 divided by 1.6

https://www.sidefx.com/docs/houdini/vex/functions/refract.html [www.sidefx.com]
User Avatar
Member
1007 posts
Joined: April 2017
Offline
Oh, that "N1/N2" might be where I'm goin' wrong!
User Avatar
Member
1007 posts
Joined: April 2017
Offline
Works like a charm! I baked the result onto a grid with some dispersion effect (not physically accurate).

Attachments:
Houdini_SnellsLaw_04.JPG (65.4 KB)

  • Quick Links