23 {0,
nullptr, 0,
nullptr,
nullptr},
28 b.use_custom_socket_order();
29 b.allow_any_socket_order();
31 b.add_input<
decl::Color>(
"Image").default_value({1.0f, 1.0f, 1.0f, 1.0f}).hide_value();
32 b.add_output<
decl::Color>(
"Image").align_with_previous();
35 b.add_input<
decl::Color>(
"Key Color").default_value({1.0f, 1.0f, 1.0f, 1.0f});
47 "If the distance between the color and the key color in the given color space is less "
48 "than this threshold, it is keyed");
55 "If the distance between the color and the key color in the given color space is less "
56 "than this threshold, it is partially keyed, otherwise, it is not keyed");
79 const float tolerance,
86 switch (color_space) {
99 color_vector /= 255.0f;
101 key.x, key.y, key.z, &key_vector.x, &key_vector.y, &key_vector.z,
BLI_YCC_ITU_BT709);
102 key_vector /= 255.0f;
107 bool is_opaque = difference > tolerance + falloff;
108 float alpha = is_opaque ?
color.w :
116 static auto function =
117 mf::build::SI5_SO2<float4, float4, MenuValue, float, float, float4, float>(
122 const float &tolerance,
123 const float &falloff,
125 float &matte) ->
void {
134 mf::build::exec_presets::SomeSpanOrSingle<0, 1>());
147 ntype.
ui_name =
"Distance Key";
148 ntype.
ui_description =
"Create matte based on 3D distance between colors";
151 ntype.
declare = file_ns::cmp_node_distance_matte_declare;
153 ntype.
initfunc = file_ns::node_composit_init_distance_matte;
156 ntype.
gpu_fn = file_ns::node_gpu_material;
constexpr int NODE_DEFAULT_MAX_WIDTH
#define CMP_NODE_DIST_MATTE
void rgb_to_ycc(float r, float g, float b, float *r_y, float *r_cb, float *r_cr, int colorspace)
#define BLI_YCC_ITU_BT709
CMPNodeDistanceMatteColorSpace
@ CMP_NODE_DISTANCE_MATTE_COLOR_SPACE_YCCA
@ CMP_NODE_DISTANCE_MATTE_COLOR_SPACE_RGBA
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void set_matching_fn(const mf::MultiFunction *fn)
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))
T safe_divide(const T &a, const T &b)
T distance(const T &a, const T &b)
T min(const T &a, const T &b)
T max(const T &a, const T &b)
static void node_composit_init_distance_matte(bNodeTree *, bNode *node)
static void distance_key(const float4 color, const float4 key, const CMPNodeDistanceMatteColorSpace color_space, const float tolerance, const float falloff, float4 &result, float &matte)
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
static void cmp_node_distance_matte_declare(NodeDeclarationBuilder &b)
static const EnumPropertyItem color_space_items[]
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *inputs, GPUNodeStack *outputs)
VecBase< float, 4 > float4
static void register_node_type_cmp_distance_matte()
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