Page MenuHome

refract vector operation
Needs RevisionPublic

Authored by james egien (cubic_sloth) on Jan 18 2020, 5:07 PM.



this patch adds a refract operator to the vector math node

Diff Detail

Event Timeline

@james egien (cubic_sloth) Check your white space and code is formatted properly. Use clang in your ide if you can.

For code reviewers: Could you also consider the node label patch D6375 if possible? This would mean that the scale float socket could be reused for eta and other functions added in the future.

I fixed the white spaces

Jacques Lucke (JacquesLucke) requested changes to this revision.Jan 21 2020, 11:00 AM

Please also provide an example for how this math function can be used in practice.


The formatting is not yet fixed in various places. Please run make format to format all c/c++ files correctly.

Afaik, you have to fix the formatting in osl files manually.

This revision now requires changes to proceed.Jan 21 2020, 11:00 AM

@james egien (cubic_sloth) If you are working with MSVC then you can install ClangFormat extension. It works pretty well for me.

i did what you said and used make format.
i can not think of any specific examples for the use of the refract operator but the refract operator is in both osl and glsl so there is probably a use.

Brecht Van Lommel (brecht) requested changes to this revision.Jan 27 2020, 5:06 PM

Rename Eta to IOR, for consistency with shading nodes.


Change scale to param1 and use it for both scale and eta, to avoid any performance impact.


Don't compute this for every math operation, only refraction.


Use defaults and min/max range similar to IOR in BSDF nodes.

This revision now requires changes to proceed.Jan 27 2020, 5:06 PM
james egien (cubic_sloth) marked an inline comment as done.
Brecht Van Lommel (brecht) requested changes to this revision.Feb 17 2020, 4:00 PM

This seems ok now, but needs to be updated after D6375: Nodes: Add dynamic label support for Math Nodes, so it doesn't add a new socket but rather just changes the label dynamically based on the type of operation.

This revision now requires changes to proceed.Feb 17 2020, 4:00 PM

Hi @james egien (cubic_sloth), do you still want to finish this patch? @Charlie Jolly (charlie) or me might pick it up.

james egien (cubic_sloth) marked 3 inline comments as done.Thu, Mar 19, 8:30 PM

you can finish the patch