Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_math.c
| Show First 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | switch (node->custom1) { | ||||
| } | } | ||||
| case 18: /* Absolute */ | case 18: /* Absolute */ | ||||
| { | { | ||||
| r = fabsf(a); | r = fabsf(a); | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| if (node->custom2) | |||||
| CLAMP(r, 0.0f, 1.0f); | |||||
| out[0]->vec[0] = r; | out[0]->vec[0] = r; | ||||
| } | } | ||||
| static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) | static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) | ||||
| { | { | ||||
| static const char *names[] = {"math_add", "math_subtract", "math_multiply", | static const char *names[] = {"math_add", "math_subtract", "math_multiply", | ||||
| "math_divide", "math_sine", "math_cosine", "math_tangent", "math_asin", | "math_divide", "math_sine", "math_cosine", "math_tangent", "math_asin", | ||||
| "math_acos", "math_atan", "math_pow", "math_log", "math_min", "math_max", | "math_acos", "math_atan", "math_pow", "math_log", "math_min", "math_max", | ||||
| Show All 33 Lines | case 14: | ||||
| memcpy(&tmp_in[0], &in[1], sizeof(GPUNodeStack)); | memcpy(&tmp_in[0], &in[1], sizeof(GPUNodeStack)); | ||||
| memcpy(&tmp_in[1], &in[2], sizeof(GPUNodeStack)); | memcpy(&tmp_in[1], &in[2], sizeof(GPUNodeStack)); | ||||
| GPU_stack_link(mat, names[node->custom1], tmp_in, out); | GPU_stack_link(mat, names[node->custom1], tmp_in, out); | ||||
| } | } | ||||
| break; | break; | ||||
| default: | default: | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| if (node->custom2) { | |||||
| GPUNodeStack clampns[2]; | |||||
| memcpy(&clampns[0], out, (2) * sizeof(GPUNodeStack)); | |||||
| GPU_stack_link(mat, "math_clamp", clampns, out); | |||||
sergey: You can use something like:
GPU_link(mat, "math_clamp", out[0].link, &out[0].link);
instead. | |||||
| } | |||||
| return 1; | return 1; | ||||
| } | } | ||||
| void register_node_type_sh_math(void) | void register_node_type_sh_math(void) | ||||
| { | { | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0); | sh_node_type_base(&ntype, SH_NODE_MATH, "Math", NODE_CLASS_CONVERTOR, 0); | ||||
| Show All 9 Lines | |||||
You can use something like:
instead.