Page MenuHome

refract vector operation
Needs RevisionPublic

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

Details

Summary

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.

intern/cycles/kernel/svm/svm_math_util.h
20

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.
http://docs.gl/sl4/refract

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

Rename Eta to IOR, for consistency with shading nodes.

intern/cycles/kernel/svm/svm_math.h
53–54

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

intern/cycles/kernel/svm/svm_math_util.h
28

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

source/blender/nodes/shader/nodes/node_shader_vector_math.c
31

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

This revision now requires changes to proceed.Mon, Jan 27, 5:06 PM
james egien (cubic_sloth) marked an inline comment as done.
Brecht Van Lommel (brecht) requested changes to this revision.Mon, Feb 17, 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.Mon, Feb 17, 4:00 PM