41 "If the distance between the color and the key color in the given color space is less "
42 "than this threshold, it is keyed");
49 "If the distance between the color and the key color in the given color space is less "
50 "than this threshold, it is partially keyed, otherwise, it is not keyed");
96 const float tolerance,
102 bool is_opaque = difference > tolerance + falloff;
103 float alpha = is_opaque ?
color.w :
math::max(0.0f, difference - tolerance) / falloff;
110 const float tolerance,
118 color_ycca /= 255.0f;
124 bool is_opaque = difference > tolerance + falloff;
125 float alpha = is_opaque ?
color.w :
math::max(0.0f, difference - tolerance) / falloff;
134 switch (color_space) {
137 return mf::build::SI4_SO2<float4, float4, float, float, float4, float>(
141 const float &tolerance,
142 const float &falloff,
144 float &matte) ->
void {
147 mf::build::exec_presets::SomeSpanOrSingle<0, 1>());
152 return mf::build::SI4_SO2<float4, float4, float, float, float4, float>(
156 const float &tolerance,
157 const float &falloff,
159 float &matte) ->
void {
162 mf::build::exec_presets::SomeSpanOrSingle<0, 1>());
177 ntype.
ui_name =
"Distance Key";
178 ntype.
ui_description =
"Create matte based on 3D distance between colors";
181 ntype.
declare = file_ns::cmp_node_distance_matte_declare;
182 ntype.
draw_buttons = file_ns::node_composit_buts_distance_matte;
184 ntype.
initfunc = file_ns::node_composit_init_distance_matte;
187 ntype.
gpu_fn = file_ns::node_gpu_material;
#define NODE_STORAGE_FUNCS(StorageT)
#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)
@ UI_ITEM_R_SPLIT_EMPTY_NAME
void construct_and_set_matching_fn_cb(Fn &&create_multi_function)
ColorGeometry4f default_value
void * MEM_callocN(size_t len, const char *str)
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 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 CMPNodeDistanceMatteColorSpace get_color_space(const bNode &node)
static void distance_key_ycca(const float4 &color, const float4 &key, const float tolerance, const float falloff, float4 &result, float &matte)
static void distance_key_rgba(const float4 &color, const float4 &key, const float tolerance, const float falloff, float4 &result, float &matte)
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
static void node_composit_buts_distance_matte(uiLayout *layout, bContext *, PointerRNA *ptr)
static void cmp_node_distance_matte_declare(NodeDeclarationBuilder &b)
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *inputs, GPUNodeStack *outputs)
VecBase< float, 4 > float4
VecBase< float, 3 > float3
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
VecBase< T, 2 > yz() const
std::string ui_description
void(* initfunc)(bNodeTree *ntree, bNode *node)
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
const char * enum_name_legacy
void(* draw_buttons)(uiLayout *, bContext *C, PointerRNA *ptr)
NodeDeclareFunction declare
void label(blender::StringRef name, int icon)
uiLayout & row(bool align)
void prop(PointerRNA *ptr, PropertyRNA *prop, int index, int value, eUI_Item_Flag flag, std::optional< blender::StringRef > name_opt, int icon, std::optional< blender::StringRef > placeholder=std::nullopt)