Cleanup: Compositor: Migrate color nodes to new socket builder

This commit is contained in:
Aaron Carlisle 2021-09-29 00:09:41 -04:00
parent d1220f795f
commit 756c22bb41
13 changed files with 166 additions and 138 deletions

View File

@ -24,16 +24,18 @@
#include "node_composite_util.hh"
/* **************** ALPHAOVER ******************** */
static bNodeSocketTemplate cmp_node_alphaover_in[] = {
{SOCK_FLOAT, N_("Fac"), 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, ""},
};
static bNodeSocketTemplate cmp_node_alphaover_out[] = {
{SOCK_RGBA, N_("Image")},
{-1, ""},
};
namespace blender::nodes {
static void cmp_node_alphaover_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Float>("Fac").default_value(1.0f).min(0.0f).max(1.0f).subtype(PROP_FACTOR);
b.add_input<decl::Color>("Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_input<decl::Color>("Image", "Image_001").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_output<decl::Color>("Image");
}
} // namespace blender::nodes
static void node_alphaover_init(bNodeTree *UNUSED(ntree), bNode *node)
{
@ -45,7 +47,7 @@ void register_node_type_cmp_alphaover(void)
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_ALPHAOVER, "Alpha Over", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, cmp_node_alphaover_in, cmp_node_alphaover_out);
ntype.declare = blender::nodes::cmp_node_alphaover_declare;
node_type_init(&ntype, node_alphaover_init);
node_type_storage(
&ntype, "NodeTwoFloats", node_free_standard_storage, node_copy_standard_storage);

View File

@ -25,16 +25,17 @@
/* **************** Bright and Contrast ******************** */
static bNodeSocketTemplate cmp_node_brightcontrast_in[] = {
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_FLOAT, N_("Bright"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
{SOCK_FLOAT, N_("Contrast"), 0.0f, 0.0f, 0.0f, 0.0f, -100.0f, 100.0f, PROP_NONE},
{-1, ""},
};
static bNodeSocketTemplate cmp_node_brightcontrast_out[] = {
{SOCK_RGBA, N_("Image")},
{-1, ""},
};
namespace blender::nodes {
static void cmp_node_brightcontrast_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>("Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_input<decl::Float>("Bright").min(-100.0f).max(100.0f);
b.add_input<decl::Float>("Contrast").min(-100.0f).max(100.0f);
b.add_output<decl::Color>("Image");
}
} // namespace blender::nodes
static void node_composit_init_brightcontrast(bNodeTree *UNUSED(ntree), bNode *node)
{
@ -46,7 +47,7 @@ void register_node_type_cmp_brightcontrast(void)
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, cmp_node_brightcontrast_in, cmp_node_brightcontrast_out);
ntype.declare = blender::nodes::cmp_node_brightcontrast_declare;
node_type_init(&ntype, node_composit_init_brightcontrast);
nodeRegisterType(&ntype);

View File

@ -24,16 +24,17 @@
#include "node_composite_util.hh"
/* ******************* Color Balance ********************************* */
static bNodeSocketTemplate cmp_node_colorbalance_in[] = {
{SOCK_FLOAT, N_("Fac"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, ""},
};
static bNodeSocketTemplate cmp_node_colorbalance_out[] = {
{SOCK_RGBA, N_("Image")},
{-1, ""},
};
namespace blender::nodes {
static void cmp_node_colorbalance_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Float>("Fac").default_value(1.0f).min(0.0f).max(1.0f).subtype(PROP_FACTOR);
b.add_input<decl::Color>("Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_output<decl::Color>("Image");
}
} // namespace blender::nodes
/* Sync functions update formula parameters for other modes, such that the result is comparable.
* Note that the results are not exactly the same due to differences in color handling
@ -84,7 +85,7 @@ void register_node_type_cmp_colorbalance(void)
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_COLORBALANCE, "Color Balance", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, cmp_node_colorbalance_in, cmp_node_colorbalance_out);
ntype.declare = blender::nodes::cmp_node_colorbalance_declare;
node_type_size(&ntype, 400, 200, 400);
node_type_init(&ntype, node_composit_init_colorbalance);
node_type_storage(

View File

@ -23,17 +23,18 @@
#include "node_composite_util.hh"
/* ******************* Color Balance ********************************* */
static bNodeSocketTemplate cmp_node_colorcorrection_in[] = {
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_FLOAT, N_("Mask"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_NONE},
{-1, ""},
};
/* ******************* Color Correction ********************************* */
static bNodeSocketTemplate cmp_node_colorcorrection_out[] = {
{SOCK_RGBA, N_("Image")},
{-1, ""},
};
namespace blender::nodes {
static void cmp_node_colorcorrection_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>("Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_input<decl::Float>("Mask").default_value(1.0f).min(0.0f).max(1.0f);
b.add_output<decl::Color>("Image");
}
} // namespace blender::nodes
static void node_composit_init_colorcorrection(bNodeTree *UNUSED(ntree), bNode *node)
{
@ -70,7 +71,7 @@ void register_node_type_cmp_colorcorrection(void)
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_COLORCORRECTION, "Color Correction", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, cmp_node_colorcorrection_in, cmp_node_colorcorrection_out);
ntype.declare = blender::nodes::cmp_node_colorcorrection_declare;
node_type_size(&ntype, 400, 200, 600);
node_type_init(&ntype, node_composit_init_colorcorrection);
node_type_storage(

View File

@ -85,18 +85,19 @@ void register_node_type_cmp_curve_vec(void)
}
/* **************** CURVE RGB ******************** */
static bNodeSocketTemplate cmp_node_curve_rgb_in[] = {
{SOCK_FLOAT, N_("Fac"), 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, PROP_FACTOR},
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_RGBA, N_("Black Level"), 0.0f, 0.0f, 0.0f, 1.0f},
{SOCK_RGBA, N_("White Level"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, ""},
};
static bNodeSocketTemplate cmp_node_curve_rgb_out[] = {
{SOCK_RGBA, N_("Image")},
{-1, ""},
};
namespace blender::nodes {
static void cmp_node_rgbcurves_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Float>("Fac").default_value(1.0f).min(-1.0f).max(1.0f).subtype(PROP_FACTOR);
b.add_input<decl::Color>("Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_input<decl::Color>("Black Level").default_value({0.0f, 0.0f, 0.0f, 1.0f});
b.add_input<decl::Color>("White Level").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_output<decl::Color>("Image");
}
} // namespace blender::nodes
static void node_composit_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode *node)
{
@ -108,7 +109,7 @@ void register_node_type_cmp_curve_rgb(void)
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, cmp_node_curve_rgb_in, cmp_node_curve_rgb_out);
ntype.declare = blender::nodes::cmp_node_rgbcurves_declare;
node_type_size(&ntype, 200, 140, 320);
node_type_init(&ntype, node_composit_init_curve_rgb);
node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);

View File

@ -25,22 +25,23 @@
/* **************** Exposure ******************** */
static bNodeSocketTemplate cmp_node_exposure_in[] = {
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_FLOAT, N_("Exposure"), 0.0f, 0.0f, 0.0f, 0.0f, -10.0f, 10.0f, PROP_NONE},
{-1, ""},
};
static bNodeSocketTemplate cmp_node_exposure_out[] = {
{SOCK_RGBA, N_("Image")},
{-1, ""},
};
namespace blender::nodes {
static void cmp_node_exposure_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>("Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_input<decl::Float>("Exposure").min(-10.0f).max(10.0f);
b.add_output<decl::Color>("Image");
}
} // namespace blender::nodes
void register_node_type_cmp_exposure(void)
{
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_EXPOSURE, "Exposure", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, cmp_node_exposure_in, cmp_node_exposure_out);
ntype.declare = blender::nodes::cmp_node_exposure_declare;
nodeRegisterType(&ntype);
}

View File

@ -25,22 +25,27 @@
/* **************** Gamma Tools ******************** */
static bNodeSocketTemplate cmp_node_gamma_in[] = {
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_FLOAT, N_("Gamma"), 1.0f, 0.0f, 0.0f, 0.0f, 0.001f, 10.0f, PROP_UNSIGNED},
{-1, ""},
};
static bNodeSocketTemplate cmp_node_gamma_out[] = {
{SOCK_RGBA, N_("Image")},
{-1, ""},
};
namespace blender::nodes {
static void cmp_node_gamma_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>("Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_input<decl::Float>("Gamma")
.default_value(1.0f)
.min(0.001f)
.max(10.0f)
.subtype(PROP_UNSIGNED);
b.add_output<decl::Color>("Image");
}
} // namespace blender::nodes
void register_node_type_cmp_gamma(void)
{
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_GAMMA, "Gamma", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, cmp_node_gamma_in, cmp_node_gamma_out);
ntype.declare = blender::nodes::cmp_node_gamma_declare;
nodeRegisterType(&ntype);
}

View File

@ -24,25 +24,31 @@
#include "node_composite_util.hh"
/* **************** Hue Saturation ******************** */
static bNodeSocketTemplate cmp_node_hue_sat_in[] = {
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_FLOAT, N_("Hue"), 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{SOCK_FLOAT, N_("Saturation"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_FACTOR},
{SOCK_FLOAT, N_("Value"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 2.0f, PROP_FACTOR},
{SOCK_FLOAT, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{-1, ""},
};
static bNodeSocketTemplate cmp_node_hue_sat_out[] = {
{SOCK_RGBA, N_("Image")},
{-1, ""},
};
namespace blender::nodes {
static void cmp_node_huesatval_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>("Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_input<decl::Float>("Hue").default_value(0.5f).min(0.0f).max(1.0f).subtype(PROP_FACTOR);
b.add_input<decl::Float>("Saturation")
.default_value(1.0f)
.min(0.0f)
.max(2.0f)
.subtype(PROP_FACTOR);
b.add_input<decl::Float>("Value").default_value(1.0f).min(0.0f).max(2.0f).subtype(PROP_FACTOR);
b.add_input<decl::Float>("Fac").default_value(1.0f).min(0.0f).max(1.0f).subtype(PROP_FACTOR);
b.add_output<decl::Color>("Image");
}
} // namespace blender::nodes
void register_node_type_cmp_hue_sat(void)
{
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_HUE_SAT, "Hue Saturation Value", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, cmp_node_hue_sat_in, cmp_node_hue_sat_out);
ntype.declare = blender::nodes::cmp_node_huesatval_declare;
nodeRegisterType(&ntype);
}

View File

@ -23,16 +23,16 @@
#include "node_composite_util.hh"
static bNodeSocketTemplate cmp_node_huecorrect_in[] = {
{SOCK_FLOAT, N_("Fac"), 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, PROP_FACTOR},
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, ""},
};
namespace blender::nodes {
static bNodeSocketTemplate cmp_node_huecorrect_out[] = {
{SOCK_RGBA, N_("Image")},
{-1, ""},
};
static void cmp_node_huecorrect_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Float>("Fac").default_value(1.0f).min(0.0f).max(1.0f).subtype(PROP_FACTOR);
b.add_input<decl::Color>("Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_output<decl::Color>("Image");
}
} // namespace blender::nodes
static void node_composit_init_huecorrect(bNodeTree *UNUSED(ntree), bNode *node)
{
@ -56,7 +56,7 @@ void register_node_type_cmp_huecorrect(void)
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_HUECORRECT, "Hue Correct", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, cmp_node_huecorrect_in, cmp_node_huecorrect_out);
ntype.declare = blender::nodes::cmp_node_huecorrect_declare;
node_type_size(&ntype, 320, 140, 500);
node_type_init(&ntype, node_composit_init_huecorrect);
node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);

View File

@ -24,12 +24,17 @@
#include "node_composite_util.hh"
/* **************** INVERT ******************** */
static bNodeSocketTemplate cmp_node_invert_in[] = {
{SOCK_FLOAT, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{SOCK_RGBA, N_("Color"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, ""}};
static bNodeSocketTemplate cmp_node_invert_out[] = {{SOCK_RGBA, N_("Color")}, {-1, ""}};
namespace blender::nodes {
static void cmp_node_invert_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Float>("Fac").default_value(1.0f).min(0.0f).max(1.0f).subtype(PROP_FACTOR);
b.add_input<decl::Color>("Color").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_output<decl::Color>("Color");
}
} // namespace blender::nodes
static void node_composit_init_invert(bNodeTree *UNUSED(ntree), bNode *node)
{
@ -42,7 +47,7 @@ void register_node_type_cmp_invert(void)
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, cmp_node_invert_in, cmp_node_invert_out);
ntype.declare = blender::nodes::cmp_node_invert_declare;
node_type_init(&ntype, node_composit_init_invert);
nodeRegisterType(&ntype);

View File

@ -24,16 +24,18 @@
#include "node_composite_util.hh"
/* **************** MIX RGB ******************** */
static bNodeSocketTemplate cmp_node_mix_rgb_in[] = {
{SOCK_FLOAT, N_("Fac"), 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_FACTOR},
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, ""},
};
static bNodeSocketTemplate cmp_node_mix_rgb_out[] = {
{SOCK_RGBA, N_("Image")},
{-1, ""},
};
namespace blender::nodes {
static void cmp_node_mixrgb_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Float>("Fac").default_value(1.0f).min(0.0f).max(1.0f).subtype(PROP_FACTOR);
b.add_input<decl::Color>("Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_input<decl::Color>("Image", "Image_001").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_output<decl::Color>("Image");
}
} // namespace blender::nodes
/* custom1 = mix type */
void register_node_type_cmp_mix_rgb(void)
@ -41,7 +43,7 @@ void register_node_type_cmp_mix_rgb(void)
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_MIX_RGB, "Mix", NODE_CLASS_OP_COLOR, NODE_PREVIEW);
node_type_socket_templates(&ntype, cmp_node_mix_rgb_in, cmp_node_mix_rgb_out);
ntype.declare = blender::nodes::cmp_node_mixrgb_declare;
node_type_label(&ntype, node_blend_label);
nodeRegisterType(&ntype);

View File

@ -23,14 +23,15 @@
#include "node_composite_util.hh"
static bNodeSocketTemplate cmp_node_tonemap_in[] = {
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{-1, ""},
};
static bNodeSocketTemplate cmp_node_tonemap_out[] = {
{SOCK_RGBA, N_("Image")},
{-1, ""},
};
namespace blender::nodes {
static void cmp_node_tonemap_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>("Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_output<decl::Color>("Image");
}
} // namespace blender::nodes
static void node_composit_init_tonemap(bNodeTree *UNUSED(ntree), bNode *node)
{
@ -53,7 +54,7 @@ void register_node_type_cmp_tonemap(void)
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_TONEMAP, "Tonemap", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, cmp_node_tonemap_in, cmp_node_tonemap_out);
ntype.declare = blender::nodes::cmp_node_tonemap_declare;
node_type_init(&ntype, node_composit_init_tonemap);
node_type_storage(&ntype, "NodeTonemap", node_free_standard_storage, node_copy_standard_storage);

View File

@ -24,26 +24,28 @@
#include "node_composite_util.hh"
/* **************** Z COMBINE ******************** */
/* lazy coder NOTE: node->custom2 is abused to send signal. */
static bNodeSocketTemplate cmp_node_zcombine_in[] = {
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_FLOAT, N_("Z"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 10000.0f, PROP_NONE},
{SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
{SOCK_FLOAT, N_("Z"), 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 10000.0f, PROP_NONE},
{-1, ""},
};
static bNodeSocketTemplate cmp_node_zcombine_out[] = {
{SOCK_RGBA, N_("Image")},
{SOCK_FLOAT, N_("Z")},
{-1, ""},
};
namespace blender::nodes {
static void cmp_node_zcombine_declare(NodeDeclarationBuilder &b)
{
b.add_input<decl::Color>("Image").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_input<decl::Float>("Z").default_value(1.0f).min(0.0f).max(10000.0f);
b.add_input<decl::Color>("Image", "Image_001").default_value({1.0f, 1.0f, 1.0f, 1.0f});
b.add_input<decl::Float>("Z", "Z_001").default_value(1.0f).min(0.0f).max(10000.0f);
b.add_output<decl::Color>("Image");
b.add_output<decl::Float>("Z");
}
} // namespace blender::nodes
/* lazy coder NOTE: node->custom2 is abused to send signal. */
void register_node_type_cmp_zcombine(void)
{
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_ZCOMBINE, "Z Combine", NODE_CLASS_OP_COLOR, 0);
node_type_socket_templates(&ntype, cmp_node_zcombine_in, cmp_node_zcombine_out);
ntype.declare = blender::nodes::cmp_node_zcombine_declare;
nodeRegisterType(&ntype);
}