Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_math.c
| Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | static const char *names[] = { | ||||
| [NODE_MATH_COSINE] = "math_cosine", | [NODE_MATH_COSINE] = "math_cosine", | ||||
| [NODE_MATH_TANGENT] = "math_tangent", | [NODE_MATH_TANGENT] = "math_tangent", | ||||
| [NODE_MATH_ARCSINE] = "math_arcsine", | [NODE_MATH_ARCSINE] = "math_arcsine", | ||||
| [NODE_MATH_ARCCOSINE] = "math_arccosine", | [NODE_MATH_ARCCOSINE] = "math_arccosine", | ||||
| [NODE_MATH_ARCTANGENT] = "math_arctangent", | [NODE_MATH_ARCTANGENT] = "math_arctangent", | ||||
| [NODE_MATH_ARCTAN2] = "math_arctan2", | [NODE_MATH_ARCTAN2] = "math_arctan2", | ||||
| }; | }; | ||||
| GPU_stack_link(mat, node, names[node->custom1], in, out); | if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) { | ||||
| int ret = GPU_stack_link(mat, node, names[node->custom1], in, out); | |||||
| if (node->custom2 & SHD_MATH_CLAMP) { | if (ret && node->custom2 & SHD_MATH_CLAMP) { | ||||
| float min[3] = {0.0f, 0.0f, 0.0f}; | float min[3] = {0.0f, 0.0f, 0.0f}; | ||||
| float max[3] = {1.0f, 1.0f, 1.0f}; | float max[3] = {1.0f, 1.0f, 1.0f}; | ||||
| GPU_link(mat, "clamp_value", out[0].link, GPU_constant(min), GPU_constant(max), &out[0].link); | GPU_link(mat, "clamp_value", out[0].link, GPU_constant(min), GPU_constant(max), &out[0].link); | ||||
| } | } | ||||
| return 1; | return ret; | ||||
| } | |||||
| else { | |||||
| return 0; | |||||
| } | |||||
| } | } | ||||
| static void node_shader_update_math(bNodeTree *UNUSED(ntree), bNode *node) | static void node_shader_update_math(bNodeTree *UNUSED(ntree), bNode *node) | ||||
| { | { | ||||
| bNodeSocket *sock = BLI_findlink(&node->inputs, 1); | bNodeSocket *sock = BLI_findlink(&node->inputs, 1); | ||||
| nodeSetSocketAvailability(sock, | nodeSetSocketAvailability(sock, | ||||
| !ELEM(node->custom1, | !ELEM(node->custom1, | ||||
| NODE_MATH_SQRT, | NODE_MATH_SQRT, | ||||
| Show All 25 Lines | |||||