diff options
author | Charlie Jolly <charlie> | 2021-06-11 02:01:10 +0300 |
---|---|---|
committer | Charlie Jolly <mistajolly@gmail.com> | 2021-06-11 02:01:13 +0300 |
commit | 461ba4438f90fa4945b809eeee3fed43291a3220 (patch) | |
tree | f3f00dd194b55a189f8688c50da325079b49b11b /source/blender | |
parent | d581c1b3042d3b3c5c5335cdb50e4ad73412ac25 (diff) |
Nodes: move mix rgb node to C++
Prepare node for conversion to Geometry Nodes.
There should be no functional changes.
Reviewed By: HooglyBoogly
Differential Revision: https://developer.blender.org/D11506
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/nodes/CMakeLists.txt | 2 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_mixRgb.cc (renamed from source/blender/nodes/shader/nodes/node_shader_mixRgb.c) | 69 |
2 files changed, 48 insertions, 23 deletions
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt index 025ce79ffc5..fbe3377194a 100644 --- a/source/blender/nodes/CMakeLists.txt +++ b/source/blender/nodes/CMakeLists.txt @@ -242,7 +242,7 @@ set(SRC shader/nodes/node_shader_map_range.cc shader/nodes/node_shader_mapping.c shader/nodes/node_shader_math.cc - shader/nodes/node_shader_mixRgb.c + shader/nodes/node_shader_mixRgb.cc shader/nodes/node_shader_mix_shader.c shader/nodes/node_shader_normal.c shader/nodes/node_shader_normal_map.c diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.cc index 090c6216224..52f2adb10dd 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.cc @@ -61,35 +61,60 @@ static void node_shader_exec_mix_rgb(void *UNUSED(data), copy_v3_v3(out[0]->vec, col); } +static const char *gpu_shader_get_name(int mode) +{ + switch (mode) { + case MA_RAMP_BLEND: + return "mix_blend"; + case MA_RAMP_ADD: + return "mix_add"; + case MA_RAMP_MULT: + return "mix_mult"; + case MA_RAMP_SUB: + return "mix_sub"; + case MA_RAMP_SCREEN: + return "mix_screen"; + case MA_RAMP_DIV: + return "mix_div"; + case MA_RAMP_DIFF: + return "mix_diff"; + case MA_RAMP_DARK: + return "mix_dark"; + case MA_RAMP_LIGHT: + return "mix_light"; + case MA_RAMP_OVERLAY: + return "mix_overlay"; + case MA_RAMP_DODGE: + return "mix_dodge"; + case MA_RAMP_BURN: + return "mix_burn"; + case MA_RAMP_HUE: + return "mix_hue"; + case MA_RAMP_SAT: + return "mix_sat"; + case MA_RAMP_VAL: + return "mix_val"; + case MA_RAMP_COLOR: + return "mix_color"; + case MA_RAMP_SOFT: + return "mix_soft"; + case MA_RAMP_LINEAR: + return "mix_linear"; + } + + return nullptr; +} + 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", - "mix_screen", - "mix_div", - "mix_diff", - "mix_dark", - "mix_light", - "mix_overlay", - "mix_dodge", - "mix_burn", - "mix_hue", - "mix_sat", - "mix_val", - "mix_color", - "mix_soft", - "mix_linear", - }; + const char *name = gpu_shader_get_name(node->custom1); - if (node->custom1 < ARRAY_SIZE(names) && names[node->custom1]) { - int ret = GPU_stack_link(mat, node, names[node->custom1], in, out); + if (name != nullptr) { + int ret = GPU_stack_link(mat, node, name, in, out); if (ret && node->custom2 & SHD_MIXRGB_CLAMP) { const float min[3] = {0.0f, 0.0f, 0.0f}; const float max[3] = {1.0f, 1.0f, 1.0f}; |