Changeset View
Changeset View
Standalone View
Standalone View
source/blender/nodes/shader/nodes/node_shader_mixRgb.c
| Show First 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
| static void node_shader_exec_mix_rgb(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out) | static void node_shader_exec_mix_rgb(void *UNUSED(data), int UNUSED(thread), bNode *node, bNodeExecData *UNUSED(execdata), bNodeStack **in, bNodeStack **out) | ||||
| { | { | ||||
| /* stack order in: fac, col1, col2 */ | /* stack order in: fac, col1, col2 */ | ||||
| /* stack order out: col */ | /* stack order out: col */ | ||||
| float col[3]; | float col[3]; | ||||
| float fac; | float fac; | ||||
| float vec[3]; | float vec[3]; | ||||
| int i = 0; | |||||
| nodestack_get_vec(&fac, SOCK_FLOAT, in[0]); | nodestack_get_vec(&fac, SOCK_FLOAT, in[0]); | ||||
| CLAMP(fac, 0.0f, 1.0f); | CLAMP(fac, 0.0f, 1.0f); | ||||
| nodestack_get_vec(col, SOCK_VECTOR, in[1]); | nodestack_get_vec(col, SOCK_VECTOR, in[1]); | ||||
| nodestack_get_vec(vec, SOCK_VECTOR, in[2]); | nodestack_get_vec(vec, SOCK_VECTOR, in[2]); | ||||
| ramp_blend(node->custom1, col, fac, vec); | ramp_blend(node->custom1, col, fac, vec); | ||||
| if (node->custom2) | |||||
sergey: This is wrong, custom2 also has bitflag for alpha. | |||||
| for(i = 0; i < 4; ++i) | |||||
| CLAMP(col[i], 0.0f, 1.0f); | |||||
| copy_v3_v3(out[0]->vec, col); | copy_v3_v3(out[0]->vec, col); | ||||
| } | } | ||||
| static int gpu_shader_mix_rgb(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) | static int gpu_shader_mix_rgb(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED(execdata), GPUNodeStack *in, GPUNodeStack *out) | ||||
| { | { | ||||
| static const char *names[] = {"mix_blend", "mix_add", "mix_mult", "mix_sub", | static const char *names[] = {"mix_blend", "mix_add", "mix_mult", "mix_sub", | ||||
| "mix_screen", "mix_div", "mix_diff", "mix_dark", "mix_light", | "mix_screen", "mix_div", "mix_diff", "mix_dark", "mix_light", | ||||
| "mix_overlay", "mix_dodge", "mix_burn", "mix_hue", "mix_sat", | "mix_overlay", "mix_dodge", "mix_burn", "mix_hue", "mix_sat", | ||||
| "mix_val", "mix_color", "mix_soft", "mix_linear"}; | "mix_val", "mix_color", "mix_soft", "mix_linear"}; | ||||
| return GPU_stack_link(mat, names[node->custom1], in, out); | int ret = GPU_stack_link(mat, names[node->custom1], in, out); | ||||
| if (ret == 0) | |||||
| { | |||||
| return 0; | |||||
| } | |||||
| if (node->custom2) { | |||||
| GPUNodeStack clampns[2]; | |||||
| memcpy(clampns, out, (2) * sizeof(GPUNodeStack)); | |||||
| ret = GPU_stack_link(mat, "mix_clamp", clampns, out); | |||||
| } | |||||
| return ret; | |||||
| } | } | ||||
| void register_node_type_sh_mix_rgb(void) | void register_node_type_sh_mix_rgb(void) | ||||
| { | { | ||||
| static bNodeType ntype; | static bNodeType ntype; | ||||
| sh_node_type_base(&ntype, SH_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0); | sh_node_type_base(&ntype, SH_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, 0); | ||||
| node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); | node_type_compatibility(&ntype, NODE_OLD_SHADING | NODE_NEW_SHADING); | ||||
| node_type_socket_templates(&ntype, sh_node_mix_rgb_in, sh_node_mix_rgb_out); | node_type_socket_templates(&ntype, sh_node_mix_rgb_in, sh_node_mix_rgb_out); | ||||
| node_type_label(&ntype, node_blend_label); | node_type_label(&ntype, node_blend_label); | ||||
| node_type_exec(&ntype, NULL, NULL, node_shader_exec_mix_rgb); | node_type_exec(&ntype, NULL, NULL, node_shader_exec_mix_rgb); | ||||
| node_type_gpu(&ntype, gpu_shader_mix_rgb); | node_type_gpu(&ntype, gpu_shader_mix_rgb); | ||||
| nodeRegisterType(&ntype); | nodeRegisterType(&ntype); | ||||
| } | } | ||||
This is wrong, custom2 also has bitflag for alpha.