31 {0,
nullptr, 0,
nullptr,
nullptr},
39 N_(
"Limit by a single channel")},
44 N_(
"Limit by the average of the other two channels")},
45 {0,
nullptr, 0,
nullptr,
nullptr},
51 b.use_custom_socket_order();
55 b.add_input<
decl::Color>(
"Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
84 .description(
"Specifies the limiting strength of the limit channel");
87 b.add_panel(
"Spill Strength").default_closed(
true);
92 "If enabled, the spill strength for each color channel can be specified. If disabled, "
93 "the spill channel will have a unit scale, while other channels will be zero");
95 .default_value({0.0f, 1.0f, 0.0f, 1.0f})
96 .description(
"Specifies the spilling strength of each color channel");
120 const int spill_channel,
121 const int limit_channel)
126 return int2((spill_channel + 1) % 3, (spill_channel + 2) % 3);
130 return int2(limit_channel);
134 const float4 spill_strength,
135 const int spill_channel)
137 if (use_spill_strength) {
139 scale[spill_channel] *= -1.0f;
144 scale[spill_channel] = -1.0f;
150 const int spill_channel,
152 const int limit_channel,
153 const float limit_scale,
154 const bool use_spill_strength,
155 const float4 spill_strength)
158 const float average_limit = (
color[limit_channels.x] +
color[limit_channels.y]) / 2.0f;
159 const float map = factor *
color[spill_channel] - limit_scale * average_limit;
161 use_spill_strength, spill_strength, spill_channel);
167 static auto function = mf::build::
168 SI8_SO<float4, float, MenuValue, MenuValue, MenuValue, float, bool, float4, float4>(
175 const float &limit_scale,
176 const bool &use_spill_strength,
187 mf::build::exec_presets::SomeSpanOrSingle<0>());
202 "Remove colors from a blue or green screen, by reducing one RGB channel compared to the "
206 ntype.
declare = file_ns::cmp_node_color_spill_declare;
207 ntype.
initfunc = file_ns::node_composit_init_color_spill;
210 ntype.
gpu_fn = file_ns::node_gpu_material;
constexpr int NODE_DEFAULT_MAX_WIDTH
#define CMP_NODE_COLOR_SPILL
#define BLT_I18NCONTEXT_COLOR
CMPNodeColorSpillLimitAlgorithm
@ CMP_NODE_COLOR_SPILL_LIMIT_ALGORITHM_AVERAGE
@ CMP_NODE_COLOR_SPILL_LIMIT_ALGORITHM_SINGLE
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
DeclType::Builder & add_input(StringRef name, StringRef identifier="")
void set_matching_fn(const mf::MultiFunction *fn)
std::optional< std::string > translation_context
void * MEM_callocN(size_t len, const char *str)
void node_type_size(bNodeType &ntype, int width, int minwidth, int maxwidth)
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))
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_composit_init_color_spill(bNodeTree *, bNode *node)
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
static float3 compute_spill_scale(const bool use_spill_strength, const float4 spill_strength, const int spill_channel)
static void cmp_node_color_spill_declare(NodeDeclarationBuilder &b)
static const EnumPropertyItem rgb_channel_items[]
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 3 > float3
static void register_node_type_cmp_color_spill()
void cmp_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
static blender::bke::bNodeSocketTemplate outputs[]
static blender::bke::bNodeSocketTemplate inputs[]
void node_free_standard_storage(bNode *node)
void node_copy_standard_storage(bNodeTree *, bNode *dest_node, const bNode *src_node)
VecBase< T, 3 > xyz() const
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
const char * enum_name_legacy
NodeDeclareFunction declare