33 b.use_custom_socket_order();
34 b.allow_any_socket_order();
36 b.add_input<
decl::Color>(
"Image").default_value({1.0f, 1.0f, 1.0f, 1.0f}).hide_value();
37 b.add_output<
decl::Color>(
"Image").align_with_previous();
40 b.add_input<
decl::Color>(
"Key Color").default_value({1.0f, 1.0f, 1.0f, 1.0f});
45 "If the angle between the color and the key color in CrCb space is less than this "
46 "minimum angle, it is keyed");
51 "If the angle between the color and the key color in CrCb space is larger than this "
52 "maximum angle, it is not keyed");
59 "Controls the falloff between keyed and non-keyed values. 0 means completely sharp and "
60 "1 means completely smooth");
92 float2 color_cc = color_ycca.
yz() * 2.0f - 1.0f;
100 float foreground_key = color_cc.x - (
math::abs(color_cc.y) /
math::tan(maximum / 2.0f));
104 float alpha =
color.w;
105 if (foreground_key > 0.0f) {
106 alpha = 1.0f - (foreground_key / falloff);
121 return mf::build::SI5_SO2<float4, float4, float, float, float, float4, float>(
125 const float &minimum,
126 const float &maximum,
127 const float &falloff,
129 float &matte) ->
void {
132 mf::build::exec_presets::SomeSpanOrSingle<0, 1>());
149 ntype.
declare = file_ns::cmp_node_chroma_matte_declare;
151 ntype.
gpu_fn = file_ns::node_gpu_material;
constexpr int NODE_DEFAULT_MAX_WIDTH
#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_type_size(bNodeType &ntype, int width, int minwidth, int maxwidth)
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