29 {0,
nullptr, 0,
nullptr,
nullptr},
37 N_(
"Limit by a single channel")},
42 N_(
"Limit by the average of the other two channels")},
43 {0,
nullptr, 0,
nullptr,
nullptr},
49 b.use_custom_socket_order();
53 b.add_input<
decl::Color>(
"Image"_ustr).default_value({1.0f, 1.0f, 1.0f, 1.0f});
82 .description(
"Specifies the limiting strength of the limit channel");
85 b.add_panel(
"Spill Strength"_ustr).default_closed(
true);
90 "If enabled, the spill strength for each color channel can be specified. If disabled, "
91 "the spill channel will have a unit scale, while other channels will be zero");
93 .default_value({0.0f, 1.0f, 0.0f, 1.0f})
94 .description(
"Specifies the spilling strength of each color channel");
100 node->storage = MEM_new<NodeColorspill>(__func__);
118 const int spill_channel,
119 const int limit_channel)
124 return int2((spill_channel + 1) % 3, (spill_channel + 2) % 3);
128 return int2(limit_channel);
132 const float4 spill_strength,
133 const int spill_channel)
135 if (use_spill_strength) {
137 scale[spill_channel] *= -1.0f;
142 scale[spill_channel] = -1.0f;
148 const int spill_channel,
150 const int limit_channel,
151 const float limit_scale,
152 const bool use_spill_strength,
153 const float4 spill_strength)
156 const float average_limit = (
color[limit_channels.x] +
color[limit_channels.y]) / 2.0f;
157 const float map = factor *
color[spill_channel] - limit_scale * average_limit;
159 use_spill_strength, spill_strength, spill_channel);
167 static auto function =
168 mf::build::SI8_SO<Color, float, MenuValue, MenuValue, MenuValue, float, bool, Color, Color>(
175 const float &limit_scale,
176 const bool &use_spill_strength,
187 mf::build::exec_presets::SomeSpanOrSingle<0>());
198 "Remove colors from a blue or green screen, by reducing one RGB channel compared to the "
#define CMP_NODE_COLOR_SPILL
#define BLT_I18NCONTEXT_COLOR
#define NOD_REGISTER_NODE(REGISTER_FUNC)
DeclType::Builder & add_input(UString name, UString identifier=""_ustr)
void set_matching_fn(const mf::MultiFunction *fn)
std::optional< std::string > translation_context
float3x3 scale(float3x3 mat, float2 scale)
void node_register_type(bNodeType &ntype)
void node_type_storage(bNodeType &ntype, std::optional< StringRefNull > storagename, void(*freefunc)(bNode *node), void(*copyfunc)(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node))
ColorSceneLinear4f< eAlpha::Premultiplied > Color
static float4 color_spill(const float4 color, const float factor, const int spill_channel, const CMPNodeColorSpillLimitAlgorithm limit_method, const int limit_channel, const float limit_scale, const bool use_spill_strength, const float4 spill_strength)
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *inputs, GPUNodeStack *outputs)
static int2 compute_limit_channels(const CMPNodeColorSpillLimitAlgorithm limit_method, const int spill_channel, const int limit_channel)
static const EnumPropertyItem limit_method_items[]
static void node_build_multi_function(nodes::NodeMultiFunctionBuilder &builder)
static void node_register()
static float3 compute_spill_scale(const bool use_spill_strength, const float4 spill_strength, const int spill_channel)
static void node_declare(NodeDeclarationBuilder &b)
static void node_init(bNodeTree *, bNode *node)
static const EnumPropertyItem rgb_channel_items[]
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
CMPNodeColorSpillLimitAlgorithm
@ CMP_NODE_COLOR_SPILL_LIMIT_ALGORITHM_AVERAGE
@ CMP_NODE_COLOR_SPILL_LIMIT_ALGORITHM_SINGLE
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
void cmp_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
static constexpr int _160
std::string ui_description
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
void(*) initfunc(bNodeTree *ntree, bNode *node)
const char * enum_name_legacy
NodeDeclareFunction declare