34 b.add_input<
decl::Color>(
"Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
35 b.add_input<
decl::Color>(
"Key Color").default_value({1.0f, 1.0f, 1.0f, 1.0f});
40 "If the angle between the color and the key color in CrCb space is less than this "
41 "minimum angle, it is keyed");
46 "If the angle between the color and the key color in CrCb space is larger than this "
47 "maximum angle, it is not keyed");
54 "Controls the falloff between keyed and non-keyed values. 0 means completely sharp and "
55 "1 means completely smooth");
90 float2 color_cc = color_ycca.
yz() * 2.0f - 1.0f;
98 float foreground_key = color_cc.x - (
math::abs(color_cc.y) /
math::tan(maximum / 2.0f));
102 float alpha =
color.w;
103 if (foreground_key > 0.0f) {
104 alpha = 1.0f - (foreground_key / falloff);
119 return mf::build::SI5_SO2<float4, float4, float, float, float, float4, float>(
123 const float &minimum,
124 const float &maximum,
125 const float &falloff,
127 float &matte) ->
void {
130 mf::build::exec_presets::SomeSpanOrSingle<0, 1>());
147 ntype.
declare = file_ns::cmp_node_chroma_matte_declare;
149 ntype.
gpu_fn = file_ns::node_gpu_material;
#define CMP_NODE_CHROMA_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
bool GPU_stack_link(GPUMaterial *mat, const bNode *node, const char *name, GPUNodeStack *in, GPUNodeStack *out,...)
#define NOD_REGISTER_NODE(REGISTER_FUNC)
void construct_and_set_matching_fn_cb(Fn &&create_multi_function)
void node_register_type(bNodeType &ntype)
T min(const T &a, const T &b)
MatBase< T, 2, 2 > from_direction(const VecBase< T, 2 > &direction)
T atan2(const T &y, const T &x)
MatBase< T, NumCol, NumRow > normalize(const MatBase< T, NumCol, NumRow > &a)
T tan(const AngleRadianBase< T > &a)
static void cmp_node_chroma_matte_declare(NodeDeclarationBuilder &b)
static int node_gpu_material(GPUMaterial *material, bNode *node, bNodeExecData *, GPUNodeStack *inputs, GPUNodeStack *outputs)
static void node_build_multi_function(blender::nodes::NodeMultiFunctionBuilder &builder)
static void chroma_matte(const float4 &color, const float4 &key, const float &minimum, const float &maximum, const float &falloff, float4 &result, float &matte)
VecBase< float, 4 > float4
VecBase< float, 2 > float2
VecBase< float, 3 > float3
static void register_node_type_cmp_chroma_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[]
VecBase< T, 2 > yz() const
std::string ui_description
NodeGPUExecFunction gpu_fn
NodeMultiFunctionBuildFunction build_multi_function
const char * enum_name_legacy
NodeDeclareFunction declare