Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add refract node #1698

Merged

Conversation

ld-kerley
Copy link
Contributor

Adding refract node to partner with the reflect node, with a similar named interface, and implementation as a nodegraph taken from the OSL spec

vector refract (vector I, vector N, float eta)
{
         float IdotN = dot (I, N);
         float k = 1 - eta*eta * (1 - IdotN*IdotN);
         return (k < 0) ? vector(0,0,0) : (eta*I - N * (eta*IdotN + sqrt(k)));
}

which also lines up with the Kronos implementation here too.

@jstone-lucasfilm jstone-lucasfilm changed the title add refract node Add refract node Feb 6, 2024
libraries/stdlib/stdlib_defs.mtlx Outdated Show resolved Hide resolved
libraries/stdlib/stdlib_defs.mtlx Outdated Show resolved Hide resolved
ld-kerley and others added 3 commits February 6, 2024 12:41
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
Signed-off-by: Jonathan Stone <jstone@lucasfilm.com>
@jstone-lucasfilm
Copy link
Member

@ld-kerley @kwokcb One remaining question in my mind is whether this index of refraction should be named ior rather than eta, following the pattern in MaterialX nodes where the real component of IOR is named ior and the imaginary component is named extinction. I believe this choice has historically been motivated by the goal of making node interfaces as artist-focused as possible, where eta and kappa are less artistically descriptive.

Here are two examples of the current pattern for IOR in MaterialX nodes:

https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/pbrlib/pbrlib_defs.mtlx#L136
https://github.com/AcademySoftwareFoundation/MaterialX/blob/main/libraries/pbrlib/pbrlib_defs.mtlx#L79

@ld-kerley
Copy link
Contributor Author

I think consistency is important - so +1 vote for ior here if that the prevailing direction for MaterialX.

@kwokcb
Copy link
Contributor

kwokcb commented Feb 7, 2024

Correct me if I have the wrong interpretation but isn't eta the ratio of the source ior / destination ior so maybe relative_ior or ior_ratio ?

@ld-kerley
Copy link
Contributor Author

I alway refer to The Bible whenever I'm confused.

"The speed reduction is commonly summarized using the index of refraction (IOR). For example, a material with an IOR of 2 propagates light at half the speed of light. For common materials, the value is in the range 1.0–2.5 and furthermore varies with the wavelength of light. We will use the Greek letter , pronounced “eta,” to denote this quantity."

@jstone-lucasfilm
Copy link
Member

@kwokcb All of the IOR inputs in MaterialX nodes can be thought of as being relative to the IOR of the exterior medium (which is 1.0 by default), but we don't make such a distinction in our naming conventions. Following that convention, I can see the name ior as being the most consistent here, though I'm open to other ideas.

@kwokcb
Copy link
Contributor

kwokcb commented Feb 7, 2024

Sounds good to go with ior. And thanks for the eta reference @ld-kerley.

Copy link
Member

@jstone-lucasfilm jstone-lucasfilm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks excellent, thanks @ld-kerley!

@jstone-lucasfilm jstone-lucasfilm merged commit a81ed0c into AcademySoftwareFoundation:main Feb 7, 2024
31 checks passed
@ld-kerley ld-kerley deleted the add_refract_node branch May 21, 2024 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants