REFRACT(3G)

πŸ“¦
version 1.0~svn33624 Β· 4 versions
, in ubuntu jammy, ubuntu noble

✨ REFRACT β€” calculate the refraction direction for an incident vector ✨

okay bestie, welcome to the 3G manual page πŸ’– this one's all about refract, and honestly? it's giving physics class but make it cute. πŸ¦‹


🌸 NAME 🌸

refract β€” calculate the refraction direction for an incident vector

like, you give it a ray and a surface and it tells you where the light bends. no cap. πŸ’…


✨ DECLARATION ✨

here's the exact shape of it, don't @ me:

genType refract(genType I, genType N, float eta);

genDType refract(genDType I, genDType N, float eta);

two versions, one for the regular floats and one for the double-precision girlies. πŸŽ€


πŸŽ€ PARAMETERS πŸŽ€

  • I β€” Specifies the incident vector. this is the ray coming in, the main character of the story. ✨
  • N β€” Specifies the normal vector. the surface's own little vibe-check direction. perpendicular energy. πŸ’…
  • eta β€” Specifies the ratio of indices of refraction. the numbers that decide how much the light bends. πŸ”₯

πŸ’– DESCRIPTION πŸ’–

okay so. for a given incident vector I, surface normal N, and ratio of indices of refraction, eta, refract returns the refraction vector, R. that's it. that's the whole job. 🫢

and R gets calculated like this:

k = 1.0 - eta * eta * (1.0 - dot(N, I) * dot(N, I));
if (k < 0.0)
    R = genType(0.0);       // or genDType(0.0)
else
    R = eta * I - (eta * dot(N, I) + sqrt(k)) * N;

so basically: if k goes negative, everything cancels out and you get a big fat zero vector back. genType(0.0) β€” or genDType(0.0) if you're on the double-precision side. no refraction for you, sorry babe 😭

⚠️ important bestie!! the input parameters I and N should be normalized in order to achieve the desired result. like, actually. do not skip this. normalize them first or the math gets weird and you'll be confused for an hour. πŸ™ˆ

🌈 VERSION SUPPORT 🌈

here's who showed up to the party, version by version:

  • refract (genType) β€” βœ” in 1.10, βœ” in 1.20, βœ” in 1.30, βœ” in 1.40, βœ” in 1.50, βœ” in 3.30, βœ” in 4.00, βœ” in 4.10, βœ” in 4.20, βœ” in 4.30, βœ” in 4.40, βœ” in 4.50. literally every single one. iconic. πŸ‘‘
  • refract (genDType) β€” - in 1.10, - in 1.20, - in 1.30, - in 1.40, - in 1.50, - in 3.30, βœ” in 4.00, βœ” in 4.10, βœ” in 4.20, βœ” in 4.30, βœ” in 4.40, βœ” in 4.50. she was late to the function but she ATE when she arrived. πŸ’…

πŸ¦‹ SEE ALSO πŸ¦‹

  • dot()
  • reflect()

go read those too, they're the friend group. 🫢


Copyright Β© 2011-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.

Copyright Β© 2011-2014 Khronos Group


and that's the whole page bestie!! πŸ’– source situation is [FIXME: source], the date on this beauty is 01/03/2018, and yeah it lives under the REFRACT(3G) banner. now go bend some light. ✨🌈⭐

πŸ“¦ where this page comes from