Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/nodes/composite')
-rw-r--r--source/blender/nodes/composite/CMakeLists.txt2
-rw-r--r--source/blender/nodes/composite/node_composite_tree.cc15
-rw-r--r--source/blender/nodes/composite/node_composite_util.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_alpha_over.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_antialiasing.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bilateralblur.cc8
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_blur.cc233
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bokehblur.cc69
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_bokehimage.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_boxmask.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_brightness.cc8
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_channel_matte.cc8
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_chroma_matte.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_color_matte.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_color_spill.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorbalance.cc14
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc10
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_common.cc2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_composite.cc2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_crop.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc13
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_curves.cc17
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_defocus.cc4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_denoise.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_despeckle.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_diff_matte.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_dilate.cc195
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_directionalblur.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_distance_matte.cc8
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_double_edge_mask.cc2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_filter.cc2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_flip.cc2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_glare.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_huecorrect.cc4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_id_mask.cc2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_image.cc27
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_inpaint.cc2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_invert.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_keying.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_lensdist.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_levels.cc150
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_luma_matte.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_map_range.cc2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_map_uv.cc2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_map_value.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_mask.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_math.cc2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_moviedistortion.cc4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_normalize.cc47
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_output_file.cc8
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_pixelate.cc5
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_premulkey.cc2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_rotate.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_scale.cc5
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_scene_time.cc2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcomb_color.cc14
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcomb_hsva.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcomb_rgba.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcomb_ycca.cc14
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sepcomb_yuva.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_setalpha.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_split_viewer.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_sunbeams.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_switch.cc2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_switchview.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_tonemap.cc254
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_transform.cc2
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_translate.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc4
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_vec_blur.cc6
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_viewer.cc8
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_zcombine.cc2
74 files changed, 755 insertions, 615 deletions
diff --git a/source/blender/nodes/composite/CMakeLists.txt b/source/blender/nodes/composite/CMakeLists.txt
index 2537e8e93cc..8bcc2a393d3 100644
--- a/source/blender/nodes/composite/CMakeLists.txt
+++ b/source/blender/nodes/composite/CMakeLists.txt
@@ -18,6 +18,8 @@ set(INC
../../render
../../windowmanager
../../compositor/realtime_compositor
+ ../../compositor/realtime_compositor/algorithms
+ ../../compositor/realtime_compositor/cached_resources
../../../../intern/guardedalloc
# dna_type_offsets.h
diff --git a/source/blender/nodes/composite/node_composite_tree.cc b/source/blender/nodes/composite/node_composite_tree.cc
index 9792c55b590..37d4fe852be 100644
--- a/source/blender/nodes/composite/node_composite_tree.cc
+++ b/source/blender/nodes/composite/node_composite_tree.cc
@@ -36,11 +36,8 @@
# include "COM_compositor.h"
#endif
-static void composite_get_from_context(const bContext *C,
- bNodeTreeType *UNUSED(treetype),
- bNodeTree **r_ntree,
- ID **r_id,
- ID **r_from)
+static void composite_get_from_context(
+ const bContext *C, bNodeTreeType * /*treetype*/, bNodeTree **r_ntree, ID **r_id, ID **r_from)
{
Scene *scene = CTX_data_scene(C);
@@ -49,7 +46,7 @@ static void composite_get_from_context(const bContext *C,
*r_ntree = scene->nodetree;
}
-static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCallback func)
+static void foreach_nodeclass(Scene * /*scene*/, void *calldata, bNodeClassCallback func)
{
func(calldata, NODE_CLASS_INPUT, N_("Input"));
func(calldata, NODE_CLASS_OUTPUT, N_("Output"));
@@ -64,7 +61,7 @@ static void foreach_nodeclass(Scene *UNUSED(scene), void *calldata, bNodeClassCa
func(calldata, NODE_CLASS_LAYOUT, N_("Layout"));
}
-static void free_node_cache(bNodeTree *UNUSED(ntree), bNode *node)
+static void free_node_cache(bNodeTree * /*ntree*/, bNode *node)
{
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
if (sock->cache) {
@@ -158,7 +155,7 @@ static void update(bNodeTree *ntree)
ntree_update_reroute_nodes(ntree);
}
-static void composite_node_add_init(bNodeTree *UNUSED(bnodetree), bNode *bnode)
+static void composite_node_add_init(bNodeTree * /*bnodetree*/, bNode *bnode)
{
/* Composite node will only show previews for input classes
* by default, other will be hidden
@@ -168,7 +165,7 @@ static void composite_node_add_init(bNodeTree *UNUSED(bnodetree), bNode *bnode)
}
}
-static bool composite_node_tree_socket_type_valid(bNodeTreeType *UNUSED(ntreetype),
+static bool composite_node_tree_socket_type_valid(bNodeTreeType * /*ntreetype*/,
bNodeSocketType *socket_type)
{
return nodeIsStaticSocketType(socket_type) &&
diff --git a/source/blender/nodes/composite/node_composite_util.cc b/source/blender/nodes/composite/node_composite_util.cc
index 575a32b1785..ae3352c0d1b 100644
--- a/source/blender/nodes/composite/node_composite_util.cc
+++ b/source/blender/nodes/composite/node_composite_util.cc
@@ -9,9 +9,7 @@
#include "node_composite_util.hh"
-bool cmp_node_poll_default(bNodeType *UNUSED(ntype),
- bNodeTree *ntree,
- const char **r_disabled_hint)
+bool cmp_node_poll_default(bNodeType * /*ntype*/, bNodeTree *ntree, const char **r_disabled_hint)
{
if (!STREQ(ntree->idname, "CompositorNodeTree")) {
*r_disabled_hint = TIP_("Not a compositor node tree");
@@ -20,7 +18,7 @@ bool cmp_node_poll_default(bNodeType *UNUSED(ntype),
return true;
}
-void cmp_node_update_default(bNodeTree *UNUSED(ntree), bNode *node)
+void cmp_node_update_default(bNodeTree * /*ntree*/, bNode *node)
{
LISTBASE_FOREACH (bNodeSocket *, sock, &node->outputs) {
if (sock->cache) {
diff --git a/source/blender/nodes/composite/nodes/node_composite_alpha_over.cc b/source/blender/nodes/composite/nodes/node_composite_alpha_over.cc
index 12f81da3d1c..dffdc4a9408 100644
--- a/source/blender/nodes/composite/nodes/node_composite_alpha_over.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_alpha_over.cc
@@ -37,12 +37,12 @@ static void cmp_node_alphaover_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_alphaover_init(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_alphaover_init(bNodeTree * /*ntree*/, bNode *node)
{
node->storage = MEM_cnew<NodeTwoFloats>(__func__);
}
-static void node_composit_buts_alphaover(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_alphaover(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -108,7 +108,7 @@ void register_node_type_cmp_alphaover()
cmp_node_type_base(&ntype, CMP_NODE_ALPHAOVER, "Alpha Over", NODE_CLASS_OP_COLOR);
ntype.declare = file_ns::cmp_node_alphaover_declare;
ntype.draw_buttons = file_ns::node_composit_buts_alphaover;
- node_type_init(&ntype, file_ns::node_alphaover_init);
+ ntype.initfunc = file_ns::node_alphaover_init;
node_type_storage(
&ntype, "NodeTwoFloats", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc b/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc
index 55fe3366526..8c77df08211 100644
--- a/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_antialiasing.cc
@@ -22,7 +22,7 @@ static void cmp_node_antialiasing_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_antialiasing(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_antialiasing(bNodeTree * /*ntree*/, bNode *node)
{
NodeAntiAliasingData *data = MEM_cnew<NodeAntiAliasingData>(__func__);
@@ -33,7 +33,7 @@ static void node_composit_init_antialiasing(bNodeTree *UNUSED(ntree), bNode *nod
node->storage = data;
}
-static void node_composit_buts_antialiasing(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_antialiasing(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -74,7 +74,7 @@ void register_node_type_cmp_antialiasing()
ntype.draw_buttons = file_ns::node_composit_buts_antialiasing;
ntype.flag |= NODE_PREVIEW;
node_type_size(&ntype, 170, 140, 200);
- node_type_init(&ntype, file_ns::node_composit_init_antialiasing);
+ ntype.initfunc = file_ns::node_composit_init_antialiasing;
node_type_storage(
&ntype, "NodeAntiAliasingData", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.cc b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.cc
index ac9a6c89aa4..65990677ae3 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bilateralblur.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_bilateralblur.cc
@@ -34,7 +34,7 @@ static void cmp_node_bilateralblur_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_bilateralblur(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_bilateralblur(bNodeTree * /*ntree*/, bNode *node)
{
NodeBilateralBlurData *nbbd = MEM_cnew<NodeBilateralBlurData>(__func__);
node->storage = nbbd;
@@ -43,9 +43,7 @@ static void node_composit_init_bilateralblur(bNodeTree *UNUSED(ntree), bNode *no
nbbd->sigma_space = 5.0;
}
-static void node_composit_buts_bilateralblur(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
+static void node_composit_buts_bilateralblur(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -121,7 +119,7 @@ void register_node_type_cmp_bilateralblur()
cmp_node_type_base(&ntype, CMP_NODE_BILATERALBLUR, "Bilateral Blur", NODE_CLASS_OP_FILTER);
ntype.declare = file_ns::cmp_node_bilateralblur_declare;
ntype.draw_buttons = file_ns::node_composit_buts_bilateralblur;
- node_type_init(&ntype, file_ns::node_composit_init_bilateralblur);
+ ntype.initfunc = file_ns::node_composit_init_bilateralblur;
node_type_storage(
&ntype, "NodeBilateralBlurData", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_blur.cc b/source/blender/nodes/composite/nodes/node_composite_blur.cc
index 630f18361e3..6eacc685c7e 100644
--- a/source/blender/nodes/composite/nodes/node_composite_blur.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_blur.cc
@@ -5,11 +5,7 @@
* \ingroup cmpnodes
*/
-#include <cstdint>
-
-#include "BLI_array.hh"
#include "BLI_assert.h"
-#include "BLI_index_range.hh"
#include "BLI_math_base.hh"
#include "BLI_math_vec_types.hh"
#include "BLI_math_vector.hh"
@@ -19,12 +15,13 @@
#include "UI_interface.h"
#include "UI_resources.h"
-#include "RE_pipeline.h"
-
+#include "GPU_shader.h"
#include "GPU_state.h"
#include "GPU_texture.h"
#include "COM_node_operation.hh"
+#include "COM_symmetric_blur_weights.hh"
+#include "COM_symmetric_separable_blur_weights.hh"
#include "COM_utilities.hh"
#include "node_composite_util.hh"
@@ -42,14 +39,14 @@ static void cmp_node_blur_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_blur(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_blur(bNodeTree * /*ntree*/, bNode *node)
{
NodeBlurData *data = MEM_cnew<NodeBlurData>(__func__);
data->filtertype = R_FILTER_GAUSS;
node->storage = data;
}
-static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_blur(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col, *row;
@@ -92,192 +89,7 @@ static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), Point
using namespace blender::realtime_compositor;
-/* A helper class that computes and caches a 1D GPU texture containing the weights of the separable
- * filter of the given type and radius. The filter is assumed to be symmetric, because the filter
- * functions are all even functions. Consequently, only the positive half of the filter is computed
- * and the shader takes that into consideration. */
-class SymmetricSeparableBlurWeights {
- private:
- float radius_ = 1.0f;
- int type_ = R_FILTER_GAUSS;
- GPUTexture *texture_ = nullptr;
-
- public:
- ~SymmetricSeparableBlurWeights()
- {
- if (texture_) {
- GPU_texture_free(texture_);
- }
- }
-
- /* Check if a texture containing the weights was already computed for the given filter type and
- * radius. If such texture exists, do nothing, otherwise, free the already computed texture and
- * recompute it with the given filter type and radius. */
- void update(float radius, int type)
- {
- if (texture_ && type == type_ && radius == radius_) {
- return;
- }
-
- if (texture_) {
- GPU_texture_free(texture_);
- }
-
- /* The size of filter is double the radius plus 1, but since the filter is symmetric, we only
- * compute half of it and no doubling happens. We add 1 to make sure the filter size is always
- * odd and there is a center weight. */
- const int size = math::ceil(radius) + 1;
- Array<float> weights(size);
-
- float sum = 0.0f;
-
- /* First, compute the center weight. */
- const float center_weight = RE_filter_value(type, 0.0f);
- weights[0] = center_weight;
- sum += center_weight;
-
- /* Second, compute the other weights in the positive direction, making sure to add double the
- * weight to the sum of weights because the filter is symmetric and we only loop over half of
- * it. Skip the center weight already computed by dropping the front index. */
- const float scale = radius > 0.0f ? 1.0f / radius : 0.0f;
- for (const int i : weights.index_range().drop_front(1)) {
- const float weight = RE_filter_value(type, i * scale);
- weights[i] = weight;
- sum += weight * 2.0f;
- }
-
- /* Finally, normalize the weights. */
- for (const int i : weights.index_range()) {
- weights[i] /= sum;
- }
-
- texture_ = GPU_texture_create_1d("Weights", size, 1, GPU_R16F, weights.data());
-
- type_ = type;
- radius_ = radius;
- }
-
- void bind_as_texture(GPUShader *shader, const char *texture_name)
- {
- const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name);
- GPU_texture_bind(texture_, texture_image_unit);
- }
-
- void unbind_as_texture()
- {
- GPU_texture_unbind(texture_);
- }
-};
-
-/* A helper class that computes and caches a 2D GPU texture containing the weights of the filter of
- * the given type and radius. The filter is assumed to be symmetric, because the filter functions
- * are evaluated on the normalized distance to the center. Consequently, only the upper right
- * quadrant are computed and the shader takes that into consideration. */
-class SymmetricBlurWeights {
- private:
- int type_ = R_FILTER_GAUSS;
- float2 radius_ = float2(1.0f);
- GPUTexture *texture_ = nullptr;
-
- public:
- ~SymmetricBlurWeights()
- {
- if (texture_) {
- GPU_texture_free(texture_);
- }
- }
-
- /* Check if a texture containing the weights was already computed for the given filter type and
- * radius. If such texture exists, do nothing, otherwise, free the already computed texture and
- * recompute it with the given filter type and radius. */
- void update(float2 radius, int type)
- {
- if (texture_ && type == type_ && radius == radius_) {
- return;
- }
-
- if (texture_) {
- GPU_texture_free(texture_);
- }
-
- /* The full size of filter is double the radius plus 1, but since the filter is symmetric, we
- * only compute a single quadrant of it and so no doubling happens. We add 1 to make sure the
- * filter size is always odd and there is a center weight. */
- const float2 scale = math::safe_divide(float2(1.0f), radius);
- const int2 size = int2(math::ceil(radius)) + int2(1);
- Array<float> weights(size.x * size.y);
-
- float sum = 0.0f;
-
- /* First, compute the center weight. */
- const float center_weight = RE_filter_value(type, 0.0f);
- weights[0] = center_weight;
- sum += center_weight;
-
- /* Then, compute the weights along the positive x axis, making sure to add double the weight to
- * the sum of weights because the filter is symmetric and we only loop over the positive half
- * of the x axis. Skip the center weight already computed by dropping the front index. */
- for (const int x : IndexRange(size.x).drop_front(1)) {
- const float weight = RE_filter_value(type, x * scale.x);
- weights[x] = weight;
- sum += weight * 2.0f;
- }
-
- /* Then, compute the weights along the positive y axis, making sure to add double the weight to
- * the sum of weights because the filter is symmetric and we only loop over the positive half
- * of the y axis. Skip the center weight already computed by dropping the front index. */
- for (const int y : IndexRange(size.y).drop_front(1)) {
- const float weight = RE_filter_value(type, y * scale.y);
- weights[size.x * y] = weight;
- sum += weight * 2.0f;
- }
-
- /* Then, compute the other weights in the upper right quadrant, making sure to add quadruple
- * the weight to the sum of weights because the filter is symmetric and we only loop over one
- * quadrant of it. Skip the weights along the y and x axis already computed by dropping the
- * front index. */
- for (const int y : IndexRange(size.y).drop_front(1)) {
- for (const int x : IndexRange(size.x).drop_front(1)) {
- const float weight = RE_filter_value(type, math::length(float2(x, y) * scale));
- weights[size.x * y + x] = weight;
- sum += weight * 4.0f;
- }
- }
-
- /* Finally, normalize the weights. */
- for (const int y : IndexRange(size.y)) {
- for (const int x : IndexRange(size.x)) {
- weights[size.x * y + x] /= sum;
- }
- }
-
- texture_ = GPU_texture_create_2d("Weights", size.x, size.y, 1, GPU_R16F, weights.data());
-
- type_ = type;
- radius_ = radius;
- }
-
- void bind_as_texture(GPUShader *shader, const char *texture_name)
- {
- const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name);
- GPU_texture_bind(texture_, texture_image_unit);
- }
-
- void unbind_as_texture()
- {
- GPU_texture_unbind(texture_);
- }
-};
-
class BlurOperation : public NodeOperation {
- private:
- /* Cached symmetric blur weights. */
- SymmetricBlurWeights blur_weights_;
- /* Cached symmetric blur weights for the separable horizontal pass. */
- SymmetricSeparableBlurWeights blur_horizontal_weights_;
- /* Cached symmetric blur weights for the separable vertical pass. */
- SymmetricSeparableBlurWeights blur_vertical_weights_;
-
public:
using NodeOperation::NodeOperation;
@@ -308,13 +120,16 @@ class BlurOperation : public NodeOperation {
const Result &input_image = get_input("Image");
input_image.bind_as_texture(shader, "input_tx");
- blur_weights_.update(compute_blur_radius(), node_storage(bnode()).filtertype);
- blur_weights_.bind_as_texture(shader, "weights_tx");
+ const float2 blur_radius = compute_blur_radius();
+
+ const SymmetricBlurWeights &weights = context().cache_manager().get_symmetric_blur_weights(
+ node_storage(bnode()).filtertype, blur_radius);
+ weights.bind_as_texture(shader, "weights_tx");
Domain domain = compute_domain();
if (get_extend_bounds()) {
/* Add a radius amount of pixels in both sides of the image, hence the multiply by 2. */
- domain.size += int2(math::ceil(compute_blur_radius())) * 2;
+ domain.size += int2(math::ceil(blur_radius)) * 2;
}
Result &output_image = get_result("Image");
@@ -326,7 +141,7 @@ class BlurOperation : public NodeOperation {
GPU_shader_unbind();
output_image.unbind_as_image();
input_image.unbind_as_texture();
- blur_weights_.unbind_as_texture();
+ weights.unbind_as_texture();
}
GPUTexture *execute_separable_blur_horizontal_pass()
@@ -341,12 +156,16 @@ class BlurOperation : public NodeOperation {
const Result &input_image = get_input("Image");
input_image.bind_as_texture(shader, "input_tx");
- blur_horizontal_weights_.update(compute_blur_radius().x, node_storage(bnode()).filtertype);
- blur_horizontal_weights_.bind_as_texture(shader, "weights_tx");
+ const float2 blur_radius = compute_blur_radius();
+
+ const SymmetricSeparableBlurWeights &weights =
+ context().cache_manager().get_symmetric_separable_blur_weights(
+ node_storage(bnode()).filtertype, blur_radius.x);
+ weights.bind_as_texture(shader, "weights_tx");
Domain domain = compute_domain();
if (get_extend_bounds()) {
- domain.size.x += static_cast<int>(math::ceil(compute_blur_radius().x)) * 2;
+ domain.size.x += int(math::ceil(blur_radius.x)) * 2;
}
/* We allocate an output image of a transposed size, that is, with a height equivalent to the
@@ -367,7 +186,7 @@ class BlurOperation : public NodeOperation {
GPU_shader_unbind();
input_image.unbind_as_texture();
- blur_horizontal_weights_.unbind_as_texture();
+ weights.unbind_as_texture();
GPU_texture_image_unbind(horizontal_pass_result);
return horizontal_pass_result;
@@ -386,8 +205,12 @@ class BlurOperation : public NodeOperation {
const int texture_image_unit = GPU_shader_get_texture_binding(shader, "input_tx");
GPU_texture_bind(horizontal_pass_result, texture_image_unit);
- blur_vertical_weights_.update(compute_blur_radius().y, node_storage(bnode()).filtertype);
- blur_vertical_weights_.bind_as_texture(shader, "weights_tx");
+ const float2 blur_radius = compute_blur_radius();
+
+ const SymmetricSeparableBlurWeights &weights =
+ context().cache_manager().get_symmetric_separable_blur_weights(
+ node_storage(bnode()).filtertype, blur_radius.y);
+ weights.bind_as_texture(shader, "weights_tx");
Domain domain = compute_domain();
if (get_extend_bounds()) {
@@ -405,7 +228,7 @@ class BlurOperation : public NodeOperation {
GPU_shader_unbind();
output_image.unbind_as_image();
- blur_vertical_weights_.unbind_as_texture();
+ weights.unbind_as_texture();
GPU_texture_unbind(horizontal_pass_result);
}
@@ -501,7 +324,7 @@ void register_node_type_cmp_blur()
ntype.declare = file_ns::cmp_node_blur_declare;
ntype.draw_buttons = file_ns::node_composit_buts_blur;
ntype.flag |= NODE_PREVIEW;
- node_type_init(&ntype, file_ns::node_composit_init_blur);
+ ntype.initfunc = file_ns::node_composit_init_blur;
node_type_storage(
&ntype, "NodeBlurData", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc b/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc
index 9c0617ee8c3..f09bf1f5afd 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_bokehblur.cc
@@ -43,13 +43,13 @@ static void cmp_node_bokehblur_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_bokehblur(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_bokehblur(bNodeTree * /*ntree*/, bNode *node)
{
node->custom3 = 4.0f;
node->custom4 = 16.0f;
}
-static void node_composit_buts_bokehblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_bokehblur(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "use_variable_size", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
// uiItemR(layout, ptr, "f_stop", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE); /* UNUSED */
@@ -70,10 +70,20 @@ class BokehBlurOperation : public NodeOperation {
return;
}
+ if (get_input("Size").is_single_value() || !get_variable_size()) {
+ execute_constant_size();
+ }
+ else {
+ execute_variable_size();
+ }
+ }
+
+ void execute_constant_size()
+ {
GPUShader *shader = shader_manager().get("compositor_blur");
GPU_shader_bind(shader);
- GPU_shader_uniform_1i(shader, "radius", compute_blur_radius());
+ GPU_shader_uniform_1i(shader, "radius", int(compute_blur_radius()));
GPU_shader_uniform_1b(shader, "extend_bounds", get_extend_bounds());
const Result &input_image = get_input("Image");
@@ -88,7 +98,7 @@ class BokehBlurOperation : public NodeOperation {
Domain domain = compute_domain();
if (get_extend_bounds()) {
/* Add a radius amount of pixels in both sides of the image, hence the multiply by 2. */
- domain.size += int2(compute_blur_radius() * 2);
+ domain.size += int2(int(compute_blur_radius()) * 2);
}
Result &output_image = get_result("Image");
@@ -104,7 +114,42 @@ class BokehBlurOperation : public NodeOperation {
input_mask.unbind_as_texture();
}
- int compute_blur_radius()
+ void execute_variable_size()
+ {
+ GPUShader *shader = shader_manager().get("compositor_blur_variable_size");
+ GPU_shader_bind(shader);
+
+ GPU_shader_uniform_1f(shader, "base_size", compute_blur_radius());
+ GPU_shader_uniform_1i(shader, "search_radius", get_max_size());
+
+ const Result &input_image = get_input("Image");
+ input_image.bind_as_texture(shader, "input_tx");
+
+ const Result &input_weights = get_input("Bokeh");
+ input_weights.bind_as_texture(shader, "weights_tx");
+
+ const Result &input_size = get_input("Size");
+ input_size.bind_as_texture(shader, "size_tx");
+
+ const Result &input_mask = get_input("Bounding box");
+ input_mask.bind_as_texture(shader, "mask_tx");
+
+ const Domain domain = compute_domain();
+ Result &output_image = get_result("Image");
+ output_image.allocate_texture(domain);
+ output_image.bind_as_image(shader, "output_img");
+
+ compute_dispatch_threads_at_least(shader, domain.size);
+
+ GPU_shader_unbind();
+ output_image.unbind_as_image();
+ input_image.unbind_as_texture();
+ input_weights.unbind_as_texture();
+ input_size.unbind_as_texture();
+ input_mask.unbind_as_texture();
+ }
+
+ float compute_blur_radius()
{
const int2 image_size = get_input("Image").domain().size;
const int max_size = math::max(image_size.x, image_size.y);
@@ -124,7 +169,7 @@ class BokehBlurOperation : public NodeOperation {
return true;
}
- if (compute_blur_radius() == 0) {
+ if (compute_blur_radius() == 0.0f) {
return true;
}
@@ -142,6 +187,16 @@ class BokehBlurOperation : public NodeOperation {
{
return bnode().custom1 & CMP_NODEFLAG_BLUR_EXTEND_BOUNDS;
}
+
+ bool get_variable_size()
+ {
+ return bnode().custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE;
+ }
+
+ int get_max_size()
+ {
+ return static_cast<int>(bnode().custom4);
+ }
};
static NodeOperation *get_compositor_operation(Context &context, DNode node)
@@ -160,7 +215,7 @@ void register_node_type_cmp_bokehblur()
cmp_node_type_base(&ntype, CMP_NODE_BOKEHBLUR, "Bokeh Blur", NODE_CLASS_OP_FILTER);
ntype.declare = file_ns::cmp_node_bokehblur_declare;
ntype.draw_buttons = file_ns::node_composit_buts_bokehblur;
- node_type_init(&ntype, file_ns::node_composit_init_bokehblur);
+ ntype.initfunc = file_ns::node_composit_init_bokehblur;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc b/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc
index 81cc8990d35..8b817d3a677 100644
--- a/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_bokehimage.cc
@@ -29,7 +29,7 @@ static void cmp_node_bokehimage_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_bokehimage(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_bokehimage(bNodeTree * /*ntree*/, bNode *node)
{
NodeBokehImage *data = MEM_cnew<NodeBokehImage>(__func__);
data->angle = 0.0f;
@@ -40,7 +40,7 @@ static void node_composit_init_bokehimage(bNodeTree *UNUSED(ntree), bNode *node)
node->storage = data;
}
-static void node_composit_buts_bokehimage(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_bokehimage(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "flaps", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
uiItemR(layout, ptr, "angle", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
@@ -122,7 +122,7 @@ void register_node_type_cmp_bokehimage()
ntype.declare = file_ns::cmp_node_bokehimage_declare;
ntype.draw_buttons = file_ns::node_composit_buts_bokehimage;
ntype.flag |= NODE_PREVIEW;
- node_type_init(&ntype, file_ns::node_composit_init_bokehimage);
+ ntype.initfunc = file_ns::node_composit_init_bokehimage;
node_type_storage(
&ntype, "NodeBokehImage", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_boxmask.cc b/source/blender/nodes/composite/nodes/node_composite_boxmask.cc
index 3cf0932e1b3..17b5d64de91 100644
--- a/source/blender/nodes/composite/nodes/node_composite_boxmask.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_boxmask.cc
@@ -32,7 +32,7 @@ static void cmp_node_boxmask_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Mask"));
}
-static void node_composit_init_boxmask(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_boxmask(bNodeTree * /*ntree*/, bNode *node)
{
NodeBoxMask *data = MEM_cnew<NodeBoxMask>(__func__);
data->x = 0.5;
@@ -43,7 +43,7 @@ static void node_composit_init_boxmask(bNodeTree *UNUSED(ntree), bNode *node)
node->storage = data;
}
-static void node_composit_buts_boxmask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_boxmask(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *row;
@@ -157,7 +157,7 @@ void register_node_type_cmp_boxmask()
cmp_node_type_base(&ntype, CMP_NODE_MASK_BOX, "Box Mask", NODE_CLASS_MATTE);
ntype.declare = file_ns::cmp_node_boxmask_declare;
ntype.draw_buttons = file_ns::node_composit_buts_boxmask;
- node_type_init(&ntype, file_ns::node_composit_init_boxmask);
+ ntype.initfunc = file_ns::node_composit_init_boxmask;
node_type_storage(&ntype, "NodeBoxMask", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_brightness.cc b/source/blender/nodes/composite/nodes/node_composite_brightness.cc
index fa22f551de6..08794914e91 100644
--- a/source/blender/nodes/composite/nodes/node_composite_brightness.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_brightness.cc
@@ -28,14 +28,12 @@ static void cmp_node_brightcontrast_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_brightcontrast(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_brightcontrast(bNodeTree * /*ntree*/, bNode *node)
{
node->custom1 = 1;
}
-static void node_composit_buts_brightcontrast(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
+static void node_composit_buts_brightcontrast(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "use_premultiply", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
}
@@ -83,7 +81,7 @@ void register_node_type_cmp_brightcontrast()
cmp_node_type_base(&ntype, CMP_NODE_BRIGHTCONTRAST, "Bright/Contrast", NODE_CLASS_OP_COLOR);
ntype.declare = file_ns::cmp_node_brightcontrast_declare;
ntype.draw_buttons = file_ns::node_composit_buts_brightcontrast;
- node_type_init(&ntype, file_ns::node_composit_init_brightcontrast);
+ ntype.initfunc = file_ns::node_composit_init_brightcontrast;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/composite/nodes/node_composite_channel_matte.cc b/source/blender/nodes/composite/nodes/node_composite_channel_matte.cc
index 3b825017da8..be02f1ecd00 100644
--- a/source/blender/nodes/composite/nodes/node_composite_channel_matte.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_channel_matte.cc
@@ -31,7 +31,7 @@ static void cmp_node_channel_matte_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Matte"));
}
-static void node_composit_init_channel_matte(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_channel_matte(bNodeTree * /*ntree*/, bNode *node)
{
NodeChroma *c = MEM_cnew<NodeChroma>(__func__);
node->storage = c;
@@ -46,9 +46,7 @@ static void node_composit_init_channel_matte(bNodeTree *UNUSED(ntree), bNode *no
node->custom2 = 2; /* Green Channel. */
}
-static void node_composit_buts_channel_matte(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
+static void node_composit_buts_channel_matte(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col, *row;
@@ -184,7 +182,7 @@ void register_node_type_cmp_channel_matte()
ntype.declare = file_ns::cmp_node_channel_matte_declare;
ntype.draw_buttons = file_ns::node_composit_buts_channel_matte;
ntype.flag |= NODE_PREVIEW;
- node_type_init(&ntype, file_ns::node_composit_init_channel_matte);
+ ntype.initfunc = file_ns::node_composit_init_channel_matte;
node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_chroma_matte.cc b/source/blender/nodes/composite/nodes/node_composite_chroma_matte.cc
index e5ce87169d4..4e035fcf5e0 100644
--- a/source/blender/nodes/composite/nodes/node_composite_chroma_matte.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_chroma_matte.cc
@@ -36,7 +36,7 @@ static void cmp_node_chroma_matte_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Matte"));
}
-static void node_composit_init_chroma_matte(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_chroma_matte(bNodeTree * /*ntree*/, bNode *node)
{
NodeChroma *c = MEM_cnew<NodeChroma>(__func__);
node->storage = c;
@@ -47,7 +47,7 @@ static void node_composit_init_chroma_matte(bNodeTree *UNUSED(ntree), bNode *nod
c->fstrength = 1.0f;
}
-static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_chroma_matte(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -121,7 +121,7 @@ void register_node_type_cmp_chroma_matte()
ntype.declare = file_ns::cmp_node_chroma_matte_declare;
ntype.draw_buttons = file_ns::node_composit_buts_chroma_matte;
ntype.flag |= NODE_PREVIEW;
- node_type_init(&ntype, file_ns::node_composit_init_chroma_matte);
+ ntype.initfunc = file_ns::node_composit_init_chroma_matte;
node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_color_matte.cc b/source/blender/nodes/composite/nodes/node_composite_color_matte.cc
index 08329601f14..9233f61205d 100644
--- a/source/blender/nodes/composite/nodes/node_composite_color_matte.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_color_matte.cc
@@ -32,7 +32,7 @@ static void cmp_node_color_matte_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Matte"));
}
-static void node_composit_init_color_matte(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_color_matte(bNodeTree * /*ntree*/, bNode *node)
{
NodeChroma *c = MEM_cnew<NodeChroma>(__func__);
node->storage = c;
@@ -43,7 +43,7 @@ static void node_composit_init_color_matte(bNodeTree *UNUSED(ntree), bNode *node
c->fstrength = 1.0f;
}
-static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_color_matte(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -119,7 +119,7 @@ void register_node_type_cmp_color_matte()
ntype.declare = file_ns::cmp_node_color_matte_declare;
ntype.draw_buttons = file_ns::node_composit_buts_color_matte;
ntype.flag |= NODE_PREVIEW;
- node_type_init(&ntype, file_ns::node_composit_init_color_matte);
+ ntype.initfunc = file_ns::node_composit_init_color_matte;
node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_color_spill.cc b/source/blender/nodes/composite/nodes/node_composite_color_spill.cc
index 29401d7b20f..cd129d53d6b 100644
--- a/source/blender/nodes/composite/nodes/node_composite_color_spill.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_color_spill.cc
@@ -36,7 +36,7 @@ static void cmp_node_color_spill_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_color_spill(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_color_spill(bNodeTree * /*ntree*/, bNode *node)
{
NodeColorspill *ncs = MEM_cnew<NodeColorspill>(__func__);
node->storage = ncs;
@@ -47,7 +47,7 @@ static void node_composit_init_color_spill(bNodeTree *UNUSED(ntree), bNode *node
ncs->unspill = 0; /* do not use unspill */
}
-static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_color_spill(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *row, *col;
@@ -196,7 +196,7 @@ void register_node_type_cmp_color_spill()
cmp_node_type_base(&ntype, CMP_NODE_COLOR_SPILL, "Color Spill", NODE_CLASS_MATTE);
ntype.declare = file_ns::cmp_node_color_spill_declare;
ntype.draw_buttons = file_ns::node_composit_buts_color_spill;
- node_type_init(&ntype, file_ns::node_composit_init_color_spill);
+ ntype.initfunc = file_ns::node_composit_init_color_spill;
node_type_storage(
&ntype, "NodeColorspill", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc b/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc
index e05fbf00a25..aade1b639ab 100644
--- a/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_colorbalance.cc
@@ -23,7 +23,7 @@
* (sRGB conversion happens for LGG),
* but this keeps settings comparable. */
-void ntreeCompositColorBalanceSyncFromLGG(bNodeTree *UNUSED(ntree), bNode *node)
+void ntreeCompositColorBalanceSyncFromLGG(bNodeTree * /*ntree*/, bNode *node)
{
NodeColorBalance *n = (NodeColorBalance *)node->storage;
@@ -34,7 +34,7 @@ void ntreeCompositColorBalanceSyncFromLGG(bNodeTree *UNUSED(ntree), bNode *node)
}
}
-void ntreeCompositColorBalanceSyncFromCDL(bNodeTree *UNUSED(ntree), bNode *node)
+void ntreeCompositColorBalanceSyncFromCDL(bNodeTree * /*ntree*/, bNode *node)
{
NodeColorBalance *n = (NodeColorBalance *)node->storage;
@@ -64,7 +64,7 @@ static void cmp_node_colorbalance_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_colorbalance(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_colorbalance(bNodeTree * /*ntree*/, bNode *node)
{
NodeColorBalance *n = MEM_cnew<NodeColorBalance>(__func__);
@@ -78,7 +78,7 @@ static void node_composit_init_colorbalance(bNodeTree *UNUSED(ntree), bNode *nod
node->storage = n;
}
-static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_colorbalance(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *split, *col, *row;
@@ -123,9 +123,7 @@ static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C
}
}
-static void node_composit_buts_colorbalance_ex(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
+static void node_composit_buts_colorbalance_ex(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "correction_method", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
@@ -212,7 +210,7 @@ void register_node_type_cmp_colorbalance()
ntype.draw_buttons = file_ns::node_composit_buts_colorbalance;
ntype.draw_buttons_ex = file_ns::node_composit_buts_colorbalance_ex;
node_type_size(&ntype, 400, 200, 400);
- node_type_init(&ntype, file_ns::node_composit_init_colorbalance);
+ ntype.initfunc = file_ns::node_composit_init_colorbalance;
node_type_storage(
&ntype, "NodeColorBalance", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc
index 92b10fc1877..5ff190ac2e4 100644
--- a/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_colorcorrection.cc
@@ -35,7 +35,7 @@ static void cmp_node_colorcorrection_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_colorcorrection(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_colorcorrection(bNodeTree * /*ntree*/, bNode *node)
{
NodeColorCorrection *n = MEM_cnew<NodeColorCorrection>(__func__);
n->startmidtones = 0.2f;
@@ -64,9 +64,7 @@ static void node_composit_init_colorcorrection(bNodeTree *UNUSED(ntree), bNode *
node->storage = n;
}
-static void node_composit_buts_colorcorrection(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
+static void node_composit_buts_colorcorrection(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *row;
@@ -155,7 +153,7 @@ static void node_composit_buts_colorcorrection(uiLayout *layout,
}
static void node_composit_buts_colorcorrection_ex(uiLayout *layout,
- bContext *UNUSED(C),
+ bContext * /*C*/,
PointerRNA *ptr)
{
uiLayout *row;
@@ -355,7 +353,7 @@ void register_node_type_cmp_colorcorrection()
ntype.draw_buttons = file_ns::node_composit_buts_colorcorrection;
ntype.draw_buttons_ex = file_ns::node_composit_buts_colorcorrection_ex;
node_type_size(&ntype, 400, 200, 600);
- node_type_init(&ntype, file_ns::node_composit_init_colorcorrection);
+ ntype.initfunc = file_ns::node_composit_init_colorcorrection;
node_type_storage(
&ntype, "NodeColorCorrection", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_common.cc b/source/blender/nodes/composite/nodes/node_composite_common.cc
index 8dd88d098c4..cd119684a79 100644
--- a/source/blender/nodes/composite/nodes/node_composite_common.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_common.cc
@@ -32,7 +32,7 @@ void register_node_type_cmp_group()
node_type_size(&ntype, 140, 60, 400);
ntype.labelfunc = node_group_label;
- node_type_group_update(&ntype, node_group_update);
+ ntype.group_update_func = node_group_update;
nodeRegisterType(&ntype);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_composite.cc b/source/blender/nodes/composite/nodes/node_composite_composite.cc
index 68061bb434d..24fe4e2d986 100644
--- a/source/blender/nodes/composite/nodes/node_composite_composite.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_composite.cc
@@ -30,7 +30,7 @@ static void cmp_node_composite_declare(NodeDeclarationBuilder &b)
b.add_input<decl::Float>(N_("Z")).default_value(1.0f).min(0.0f).max(1.0f);
}
-static void node_composit_buts_composite(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_composite(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "use_alpha", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc b/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc
index e36da39cca1..24928acedd9 100644
--- a/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc
@@ -24,7 +24,7 @@ static void CMP_NODE_CONVERT_COLOR_SPACE_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_convert_colorspace(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_convert_colorspace(bNodeTree * /*ntree*/, bNode *node)
{
NodeConvertColorSpace *ncs = static_cast<NodeConvertColorSpace *>(
MEM_callocN(sizeof(NodeConvertColorSpace), "node colorspace"));
@@ -42,7 +42,7 @@ static void node_composit_init_convert_colorspace(bNodeTree *UNUSED(ntree), bNod
}
static void node_composit_buts_convert_colorspace(uiLayout *layout,
- bContext *UNUSED(C),
+ bContext * /*C*/,
PointerRNA *ptr)
{
uiItemR(layout, ptr, "from_color_space", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
@@ -78,7 +78,7 @@ void register_node_type_cmp_convert_color_space(void)
ntype.declare = file_ns::CMP_NODE_CONVERT_COLOR_SPACE_declare;
ntype.draw_buttons = file_ns::node_composit_buts_convert_colorspace;
node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
- node_type_init(&ntype, file_ns::node_composit_init_convert_colorspace);
+ ntype.initfunc = file_ns::node_composit_init_convert_colorspace;
node_type_storage(
&ntype, "NodeConvertColorSpace", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_crop.cc b/source/blender/nodes/composite/nodes/node_composite_crop.cc
index 13d02a707be..4539d2af92d 100644
--- a/source/blender/nodes/composite/nodes/node_composite_crop.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_crop.cc
@@ -37,7 +37,7 @@ static void cmp_node_crop_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_crop(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_crop(bNodeTree * /*ntree*/, bNode *node)
{
NodeTwoXYs *nxy = MEM_cnew<NodeTwoXYs>(__func__);
node->storage = nxy;
@@ -47,7 +47,7 @@ static void node_composit_init_crop(bNodeTree *UNUSED(ntree), bNode *node)
nxy->y2 = 0;
}
-static void node_composit_buts_crop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_crop(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -230,7 +230,7 @@ void register_node_type_cmp_crop()
cmp_node_type_base(&ntype, CMP_NODE_CROP, "Crop", NODE_CLASS_DISTORT);
ntype.declare = file_ns::cmp_node_crop_declare;
ntype.draw_buttons = file_ns::node_composit_buts_crop;
- node_type_init(&ntype, file_ns::node_composit_init_crop);
+ ntype.initfunc = file_ns::node_composit_init_crop;
node_type_storage(&ntype, "NodeTwoXYs", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc
index 7e5544381a4..e95a306976c 100644
--- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc
@@ -234,7 +234,7 @@ static bNodeSocketTemplate cmp_node_cryptomatte_out[] = {
{-1, ""},
};
-static void node_init_cryptomatte(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_init_cryptomatte(bNodeTree * /*ntree*/, bNode *node)
{
NodeCryptomatte *user = MEM_cnew<NodeCryptomatte>(__func__);
node->storage = user;
@@ -262,7 +262,7 @@ static void node_free_cryptomatte(bNode *node)
}
}
-static void node_copy_cryptomatte(bNodeTree *UNUSED(dest_ntree),
+static void node_copy_cryptomatte(bNodeTree * /*dst_ntree*/,
bNode *dest_node,
const bNode *src_node)
{
@@ -275,7 +275,7 @@ static void node_copy_cryptomatte(bNodeTree *UNUSED(dest_ntree),
dest_node->storage = dest_nc;
}
-static bool node_poll_cryptomatte(bNodeType *UNUSED(ntype),
+static bool node_poll_cryptomatte(bNodeType * /*ntype*/,
bNodeTree *ntree,
const char **r_disabled_hint)
{
@@ -331,7 +331,7 @@ void register_node_type_cmp_cryptomatte()
node_type_socket_templates(
&ntype, file_ns::cmp_node_cryptomatte_in, file_ns::cmp_node_cryptomatte_out);
node_type_size(&ntype, 240, 100, 700);
- node_type_init(&ntype, file_ns::node_init_cryptomatte);
+ ntype.initfunc = file_ns::node_init_cryptomatte;
ntype.initfunc_api = file_ns::node_init_api_cryptomatte;
ntype.poll = file_ns::node_poll_cryptomatte;
node_type_storage(
@@ -415,9 +415,10 @@ void register_node_type_cmp_cryptomatte_legacy()
static bNodeType ntype;
- cmp_node_type_base(&ntype, CMP_NODE_CRYPTOMATTE_LEGACY, "Cryptomatte", NODE_CLASS_MATTE);
+ cmp_node_type_base(
+ &ntype, CMP_NODE_CRYPTOMATTE_LEGACY, "Cryptomatte (Legacy)", NODE_CLASS_MATTE);
node_type_socket_templates(&ntype, nullptr, file_ns::cmp_node_cryptomatte_out);
- node_type_init(&ntype, legacy_file_ns::node_init_cryptomatte_legacy);
+ ntype.initfunc = legacy_file_ns::node_init_cryptomatte_legacy;
node_type_storage(
&ntype, "NodeCryptomatte", file_ns::node_free_cryptomatte, file_ns::node_copy_cryptomatte);
ntype.gather_link_search_ops = nullptr;
diff --git a/source/blender/nodes/composite/nodes/node_composite_curves.cc b/source/blender/nodes/composite/nodes/node_composite_curves.cc
index bf45e219730..5799c6c1a09 100644
--- a/source/blender/nodes/composite/nodes/node_composite_curves.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_curves.cc
@@ -29,7 +29,7 @@ static void cmp_node_time_declare(NodeDeclarationBuilder &b)
}
/* custom1 = start_frame, custom2 = end_frame */
-static void node_composit_init_curves_time(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_curves_time(bNodeTree * /*ntree*/, bNode *node)
{
node->custom1 = 1;
node->custom2 = 250;
@@ -80,8 +80,7 @@ class TimeCurveOperation : public NodeOperation {
if (get_start_time() == get_end_time()) {
return 0.0f;
}
- return static_cast<float>(frame_number - get_start_time()) /
- static_cast<float>(get_end_time() - get_start_time());
+ return float(frame_number - get_start_time()) / float(get_end_time() - get_start_time());
}
};
@@ -101,7 +100,7 @@ void register_node_type_cmp_curve_time()
cmp_node_type_base(&ntype, CMP_NODE_TIME, "Time Curve", NODE_CLASS_INPUT);
ntype.declare = file_ns::cmp_node_time_declare;
node_type_size(&ntype, 200, 140, 320);
- node_type_init(&ntype, file_ns::node_composit_init_curves_time);
+ ntype.initfunc = file_ns::node_composit_init_curves_time;
node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
@@ -122,12 +121,12 @@ static void cmp_node_curve_vec_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Vector>(N_("Vector"));
}
-static void node_composit_init_curve_vec(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_curve_vec(bNodeTree * /*ntree*/, bNode *node)
{
node->storage = BKE_curvemapping_add(3, -1.0f, -1.0f, 1.0f, 1.0f);
}
-static void node_buts_curvevec(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_buts_curvevec(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiTemplateCurveMapping(layout, ptr, "mapping", 'v', false, false, false, false);
}
@@ -196,7 +195,7 @@ void register_node_type_cmp_curve_vec()
ntype.declare = file_ns::cmp_node_curve_vec_declare;
ntype.draw_buttons = file_ns::node_buts_curvevec;
node_type_size(&ntype, 200, 140, 320);
- node_type_init(&ntype, file_ns::node_composit_init_curve_vec);
+ ntype.initfunc = file_ns::node_composit_init_curve_vec;
node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
@@ -223,7 +222,7 @@ static void cmp_node_rgbcurves_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_curve_rgb(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_curve_rgb(bNodeTree * /*ntree*/, bNode *node)
{
node->storage = BKE_curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
}
@@ -333,7 +332,7 @@ void register_node_type_cmp_curve_rgb()
cmp_node_type_base(&ntype, CMP_NODE_CURVE_RGB, "RGB Curves", NODE_CLASS_OP_COLOR);
ntype.declare = file_ns::cmp_node_rgbcurves_declare;
node_type_size(&ntype, 200, 140, 320);
- node_type_init(&ntype, file_ns::node_composit_init_curve_rgb);
+ ntype.initfunc = file_ns::node_composit_init_curve_rgb;
node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_defocus.cc b/source/blender/nodes/composite/nodes/node_composite_defocus.cc
index 94b4908a1bd..584cca87740 100644
--- a/source/blender/nodes/composite/nodes/node_composite_defocus.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_defocus.cc
@@ -27,7 +27,7 @@ static void cmp_node_defocus_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_defocus(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_defocus(bNodeTree * /*ntree*/, bNode *node)
{
/* defocus node */
NodeDefocus *nbd = MEM_cnew<NodeDefocus>(__func__);
@@ -111,7 +111,7 @@ void register_node_type_cmp_defocus()
cmp_node_type_base(&ntype, CMP_NODE_DEFOCUS, "Defocus", NODE_CLASS_OP_FILTER);
ntype.declare = file_ns::cmp_node_defocus_declare;
ntype.draw_buttons = file_ns::node_composit_buts_defocus;
- node_type_init(&ntype, file_ns::node_composit_init_defocus);
+ ntype.initfunc = file_ns::node_composit_init_defocus;
node_type_storage(&ntype, "NodeDefocus", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_denoise.cc b/source/blender/nodes/composite/nodes/node_composite_denoise.cc
index 0452e7cd943..9ae02dab505 100644
--- a/source/blender/nodes/composite/nodes/node_composite_denoise.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_denoise.cc
@@ -28,7 +28,7 @@ static void cmp_node_denoise_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_denonise(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_denonise(bNodeTree * /*ntree*/, bNode *node)
{
NodeDenoise *ndg = MEM_cnew<NodeDenoise>(__func__);
ndg->hdr = true;
@@ -36,7 +36,7 @@ static void node_composit_init_denonise(bNodeTree *UNUSED(ntree), bNode *node)
node->storage = ndg;
}
-static void node_composit_buts_denoise(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_denoise(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
#ifndef WITH_OPENIMAGEDENOISE
uiItemL(layout, IFACE_("Disabled, built without OpenImageDenoise"), ICON_ERROR);
@@ -82,7 +82,7 @@ void register_node_type_cmp_denoise()
cmp_node_type_base(&ntype, CMP_NODE_DENOISE, "Denoise", NODE_CLASS_OP_FILTER);
ntype.declare = file_ns::cmp_node_denoise_declare;
ntype.draw_buttons = file_ns::node_composit_buts_denoise;
- node_type_init(&ntype, file_ns::node_composit_init_denonise);
+ ntype.initfunc = file_ns::node_composit_init_denonise;
node_type_storage(&ntype, "NodeDenoise", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_despeckle.cc b/source/blender/nodes/composite/nodes/node_composite_despeckle.cc
index aa6725b8750..28ef022459b 100644
--- a/source/blender/nodes/composite/nodes/node_composite_despeckle.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_despeckle.cc
@@ -33,13 +33,13 @@ static void cmp_node_despeckle_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_despeckle(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_despeckle(bNodeTree * /*ntree*/, bNode *node)
{
node->custom3 = 0.5f;
node->custom4 = 0.5f;
}
-static void node_composit_buts_despeckle(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_despeckle(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -115,7 +115,7 @@ void register_node_type_cmp_despeckle()
ntype.declare = file_ns::cmp_node_despeckle_declare;
ntype.draw_buttons = file_ns::node_composit_buts_despeckle;
ntype.flag |= NODE_PREVIEW;
- node_type_init(&ntype, file_ns::node_composit_init_despeckle);
+ ntype.initfunc = file_ns::node_composit_init_despeckle;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc b/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc
index 8912d00a9be..c3fb0885c4d 100644
--- a/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_diff_matte.cc
@@ -32,7 +32,7 @@ static void cmp_node_diff_matte_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Matte"));
}
-static void node_composit_init_diff_matte(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_diff_matte(bNodeTree * /*ntree*/, bNode *node)
{
NodeChroma *c = MEM_cnew<NodeChroma>(__func__);
node->storage = c;
@@ -40,7 +40,7 @@ static void node_composit_init_diff_matte(bNodeTree *UNUSED(ntree), bNode *node)
c->t2 = 0.1f;
}
-static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_diff_matte(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -101,7 +101,7 @@ void register_node_type_cmp_diff_matte()
ntype.declare = file_ns::cmp_node_diff_matte_declare;
ntype.draw_buttons = file_ns::node_composit_buts_diff_matte;
ntype.flag |= NODE_PREVIEW;
- node_type_init(&ntype, file_ns::node_composit_init_diff_matte);
+ ntype.initfunc = file_ns::node_composit_init_diff_matte;
node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_dilate.cc b/source/blender/nodes/composite/nodes/node_composite_dilate.cc
index 551dfacb276..cc4e09d4d0d 100644
--- a/source/blender/nodes/composite/nodes/node_composite_dilate.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_dilate.cc
@@ -5,25 +5,20 @@
* \ingroup cmpnodes
*/
-#include <cmath>
-
-#include "BLI_array.hh"
#include "BLI_assert.h"
#include "BLI_math_base.hh"
-
-#include "DNA_scene_types.h"
+#include "BLI_math_vec_types.hh"
#include "RNA_access.h"
#include "UI_interface.h"
#include "UI_resources.h"
-#include "RE_pipeline.h"
-
#include "GPU_shader.h"
#include "GPU_state.h"
#include "GPU_texture.h"
+#include "COM_morphological_distance_feather_weights.hh"
#include "COM_node_operation.hh"
#include "COM_utilities.hh"
@@ -41,14 +36,14 @@ static void cmp_node_dilate_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Mask"));
}
-static void node_composit_init_dilateerode(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_dilateerode(bNodeTree * /*ntree*/, bNode *node)
{
NodeDilateErode *data = MEM_cnew<NodeDilateErode>(__func__);
data->falloff = PROP_SMOOTH;
node->storage = data;
}
-static void node_composit_buts_dilateerode(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_dilateerode(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "mode", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
uiItemR(layout, ptr, "distance", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
@@ -64,161 +59,7 @@ static void node_composit_buts_dilateerode(uiLayout *layout, bContext *UNUSED(C)
using namespace blender::realtime_compositor;
-/* Computes a falloff that is equal to 1 at an input of zero and decrease to zero at an input of 1,
- * with the rate of decrease depending on the falloff type. */
-static float compute_distance_falloff(float x, int falloff_type)
-{
- x = 1.0f - x;
-
- switch (falloff_type) {
- case PROP_SMOOTH:
- return 3.0f * x * x - 2.0f * x * x * x;
- case PROP_SPHERE:
- return std::sqrt(2.0f * x - x * x);
- case PROP_ROOT:
- return std::sqrt(x);
- case PROP_SHARP:
- return x * x;
- case PROP_INVSQUARE:
- return x * (2.0f - x);
- case PROP_LIN:
- return x;
- default:
- BLI_assert_unreachable();
- return x;
- }
-}
-
-/* A helper class that computes and caches 1D GPU textures containing the weights of the separable
- * Gaussian filter of the given radius as well as an inverse distance falloff of the given type and
- * radius. The weights and falloffs are symmetric, because the Gaussian and falloff functions are
- * all even functions. Consequently, only the positive half of the filter is computed and the
- * shader takes that into consideration. */
-class SymmetricSeparableMorphologicalDistanceFeatherWeights {
- private:
- int radius_ = 1;
- int falloff_type_ = PROP_SMOOTH;
- GPUTexture *weights_texture_ = nullptr;
- GPUTexture *distance_falloffs_texture_ = nullptr;
-
- public:
- ~SymmetricSeparableMorphologicalDistanceFeatherWeights()
- {
- if (weights_texture_) {
- GPU_texture_free(weights_texture_);
- }
-
- if (distance_falloffs_texture_) {
- GPU_texture_free(distance_falloffs_texture_);
- }
- }
-
- /* Check if textures containing the weights and distance falloffs were already computed for the
- * given distance falloff type and radius. If such textures exists, do nothing, otherwise, free
- * the already computed textures and recompute it with the given distance falloff type and
- * radius. */
- void update(int radius, int falloff_type)
- {
- if (weights_texture_ && distance_falloffs_texture_ && falloff_type == falloff_type_ &&
- radius == radius_) {
- return;
- }
-
- radius_ = radius;
- falloff_type_ = falloff_type;
-
- compute_weights();
- compute_distance_falloffs();
- }
-
- void compute_weights()
- {
- if (weights_texture_) {
- GPU_texture_free(weights_texture_);
- }
-
- /* The size of filter is double the radius plus 1, but since the filter is symmetric, we only
- * compute half of it and no doubling happens. We add 1 to make sure the filter size is always
- * odd and there is a center weight. */
- const int size = radius_ + 1;
- Array<float> weights(size);
-
- float sum = 0.0f;
-
- /* First, compute the center weight. */
- const float center_weight = RE_filter_value(R_FILTER_GAUSS, 0.0f);
- weights[0] = center_weight;
- sum += center_weight;
-
- /* Second, compute the other weights in the positive direction, making sure to add double the
- * weight to the sum of weights because the filter is symmetric and we only loop over half of
- * it. Skip the center weight already computed by dropping the front index. */
- const float scale = radius_ > 0.0f ? 1.0f / radius_ : 0.0f;
- for (const int i : weights.index_range().drop_front(1)) {
- const float weight = RE_filter_value(R_FILTER_GAUSS, i * scale);
- weights[i] = weight;
- sum += weight * 2.0f;
- }
-
- /* Finally, normalize the weights. */
- for (const int i : weights.index_range()) {
- weights[i] /= sum;
- }
-
- weights_texture_ = GPU_texture_create_1d("Weights", size, 1, GPU_R16F, weights.data());
- }
-
- void compute_distance_falloffs()
- {
- if (distance_falloffs_texture_) {
- GPU_texture_free(distance_falloffs_texture_);
- }
-
- /* The size of the distance falloffs is double the radius plus 1, but since the falloffs are
- * symmetric, we only compute half of them and no doubling happens. We add 1 to make sure the
- * falloffs size is always odd and there is a center falloff. */
- const int size = radius_ + 1;
- Array<float> falloffs(size);
-
- /* Compute the distance falloffs in the positive direction only, because the falloffs are
- * symmetric. */
- const float scale = radius_ > 0.0f ? 1.0f / radius_ : 0.0f;
- for (const int i : falloffs.index_range()) {
- falloffs[i] = compute_distance_falloff(i * scale, falloff_type_);
- }
-
- distance_falloffs_texture_ = GPU_texture_create_1d(
- "Distance Factors", size, 1, GPU_R16F, falloffs.data());
- }
-
- void bind_weights_as_texture(GPUShader *shader, const char *texture_name)
- {
- const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name);
- GPU_texture_bind(weights_texture_, texture_image_unit);
- }
-
- void unbind_weights_as_texture()
- {
- GPU_texture_unbind(weights_texture_);
- }
-
- void bind_distance_falloffs_as_texture(GPUShader *shader, const char *texture_name)
- {
- const int texture_image_unit = GPU_shader_get_texture_binding(shader, texture_name);
- GPU_texture_bind(distance_falloffs_texture_, texture_image_unit);
- }
-
- void unbind_distance_falloffs_as_texture()
- {
- GPU_texture_unbind(distance_falloffs_texture_);
- }
-};
-
class DilateErodeOperation : public NodeOperation {
- private:
- /* Cached symmetric blur weights and distance falloffs for the distance feature method. */
- SymmetricSeparableMorphologicalDistanceFeatherWeights distance_feather_weights_;
-
public:
using NodeOperation::NodeOperation;
@@ -393,7 +234,7 @@ class DilateErodeOperation : public NodeOperation {
/* See the discussion in the implementation for more information. */
int get_morphological_distance_threshold_radius()
{
- return static_cast<int>(math::ceil(get_inset())) + math::abs(get_distance());
+ return int(math::ceil(get_inset())) + math::abs(get_distance());
}
/* ----------------------------------------
@@ -414,9 +255,11 @@ class DilateErodeOperation : public NodeOperation {
const Result &input_image = get_input("Mask");
input_image.bind_as_texture(shader, "input_tx");
- distance_feather_weights_.update(math::abs(get_distance()), node_storage(bnode()).falloff);
- distance_feather_weights_.bind_weights_as_texture(shader, "weights_tx");
- distance_feather_weights_.bind_distance_falloffs_as_texture(shader, "falloffs_tx");
+ const MorphologicalDistanceFeatherWeights &weights =
+ context().cache_manager().get_morphological_distance_feather_weights(
+ node_storage(bnode()).falloff, math::abs(get_distance()));
+ weights.bind_weights_as_texture(shader, "weights_tx");
+ weights.bind_distance_falloffs_as_texture(shader, "falloffs_tx");
/* We allocate an output image of a transposed size, that is, with a height equivalent to the
* width of the input and vice versa. This is done as a performance optimization. The shader
@@ -437,8 +280,8 @@ class DilateErodeOperation : public NodeOperation {
GPU_shader_unbind();
input_image.unbind_as_texture();
- distance_feather_weights_.unbind_weights_as_texture();
- distance_feather_weights_.unbind_distance_falloffs_as_texture();
+ weights.unbind_weights_as_texture();
+ weights.unbind_distance_falloffs_as_texture();
GPU_texture_image_unbind(horizontal_pass_result);
return horizontal_pass_result;
@@ -453,9 +296,11 @@ class DilateErodeOperation : public NodeOperation {
const int texture_image_unit = GPU_shader_get_texture_binding(shader, "input_tx");
GPU_texture_bind(horizontal_pass_result, texture_image_unit);
- distance_feather_weights_.update(math::abs(get_distance()), node_storage(bnode()).falloff);
- distance_feather_weights_.bind_weights_as_texture(shader, "weights_tx");
- distance_feather_weights_.bind_distance_falloffs_as_texture(shader, "falloffs_tx");
+ const MorphologicalDistanceFeatherWeights &weights =
+ context().cache_manager().get_morphological_distance_feather_weights(
+ node_storage(bnode()).falloff, math::abs(get_distance()));
+ weights.bind_weights_as_texture(shader, "weights_tx");
+ weights.bind_distance_falloffs_as_texture(shader, "falloffs_tx");
const Domain domain = compute_domain();
Result &output_image = get_result("Mask");
@@ -468,8 +313,8 @@ class DilateErodeOperation : public NodeOperation {
GPU_shader_unbind();
output_image.unbind_as_image();
- distance_feather_weights_.unbind_weights_as_texture();
- distance_feather_weights_.unbind_distance_falloffs_as_texture();
+ weights.unbind_weights_as_texture();
+ weights.unbind_distance_falloffs_as_texture();
GPU_texture_unbind(horizontal_pass_result);
}
@@ -535,7 +380,7 @@ void register_node_type_cmp_dilateerode()
cmp_node_type_base(&ntype, CMP_NODE_DILATEERODE, "Dilate/Erode", NODE_CLASS_OP_FILTER);
ntype.draw_buttons = file_ns::node_composit_buts_dilateerode;
ntype.declare = file_ns::cmp_node_dilate_declare;
- node_type_init(&ntype, file_ns::node_composit_init_dilateerode);
+ ntype.initfunc = file_ns::node_composit_init_dilateerode;
node_type_storage(
&ntype, "NodeDilateErode", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_directionalblur.cc b/source/blender/nodes/composite/nodes/node_composite_directionalblur.cc
index 6e6bec70283..452c83ef1b5 100644
--- a/source/blender/nodes/composite/nodes/node_composite_directionalblur.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_directionalblur.cc
@@ -32,7 +32,7 @@ static void cmp_node_directional_blur_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_dblur(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_dblur(bNodeTree * /*ntree*/, bNode *node)
{
NodeDBlurData *ndbd = MEM_cnew<NodeDBlurData>(__func__);
node->storage = ndbd;
@@ -41,7 +41,7 @@ static void node_composit_init_dblur(bNodeTree *UNUSED(ntree), bNode *node)
ndbd->center_y = 0.5;
}
-static void node_composit_buts_dblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_dblur(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -199,7 +199,7 @@ void register_node_type_cmp_dblur()
cmp_node_type_base(&ntype, CMP_NODE_DBLUR, "Directional Blur", NODE_CLASS_OP_FILTER);
ntype.declare = file_ns::cmp_node_directional_blur_declare;
ntype.draw_buttons = file_ns::node_composit_buts_dblur;
- node_type_init(&ntype, file_ns::node_composit_init_dblur);
+ ntype.initfunc = file_ns::node_composit_init_dblur;
node_type_storage(
&ntype, "NodeDBlurData", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_distance_matte.cc b/source/blender/nodes/composite/nodes/node_composite_distance_matte.cc
index 6a786571f43..16f79f4e730 100644
--- a/source/blender/nodes/composite/nodes/node_composite_distance_matte.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_distance_matte.cc
@@ -32,7 +32,7 @@ static void cmp_node_distance_matte_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Matte"));
}
-static void node_composit_init_distance_matte(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_distance_matte(bNodeTree * /*ntree*/, bNode *node)
{
NodeChroma *c = MEM_cnew<NodeChroma>(__func__);
node->storage = c;
@@ -41,9 +41,7 @@ static void node_composit_init_distance_matte(bNodeTree *UNUSED(ntree), bNode *n
c->t2 = 0.1f;
}
-static void node_composit_buts_distance_matte(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *ptr)
+static void node_composit_buts_distance_matte(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col, *row;
@@ -125,7 +123,7 @@ void register_node_type_cmp_distance_matte()
ntype.declare = file_ns::cmp_node_distance_matte_declare;
ntype.draw_buttons = file_ns::node_composit_buts_distance_matte;
ntype.flag |= NODE_PREVIEW;
- node_type_init(&ntype, file_ns::node_composit_init_distance_matte);
+ ntype.initfunc = file_ns::node_composit_init_distance_matte;
node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_double_edge_mask.cc b/source/blender/nodes/composite/nodes/node_composite_double_edge_mask.cc
index fec7879ed78..553058cf545 100644
--- a/source/blender/nodes/composite/nodes/node_composite_double_edge_mask.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_double_edge_mask.cc
@@ -24,7 +24,7 @@ static void cmp_node_double_edge_mask_declare(NodeDeclarationBuilder &b)
}
static void node_composit_buts_double_edge_mask(uiLayout *layout,
- bContext *UNUSED(C),
+ bContext * /*C*/,
PointerRNA *ptr)
{
uiLayout *col;
diff --git a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc
index 7c031b354e5..f06b64f10b5 100644
--- a/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_ellipsemask.cc
@@ -32,7 +32,7 @@ static void cmp_node_ellipsemask_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Mask"));
}
-static void node_composit_init_ellipsemask(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_ellipsemask(bNodeTree * /*ntree*/, bNode *node)
{
NodeEllipseMask *data = MEM_cnew<NodeEllipseMask>(__func__);
data->x = 0.5;
@@ -43,7 +43,7 @@ static void node_composit_init_ellipsemask(bNodeTree *UNUSED(ntree), bNode *node
node->storage = data;
}
-static void node_composit_buts_ellipsemask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_ellipsemask(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *row;
row = uiLayoutRow(layout, true);
@@ -156,7 +156,7 @@ void register_node_type_cmp_ellipsemask()
ntype.declare = file_ns::cmp_node_ellipsemask_declare;
ntype.draw_buttons = file_ns::node_composit_buts_ellipsemask;
node_type_size(&ntype, 260, 110, 320);
- node_type_init(&ntype, file_ns::node_composit_init_ellipsemask);
+ ntype.initfunc = file_ns::node_composit_init_ellipsemask;
node_type_storage(
&ntype, "NodeEllipseMask", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_filter.cc b/source/blender/nodes/composite/nodes/node_composite_filter.cc
index bd7b443e17e..816d1009ffe 100644
--- a/source/blender/nodes/composite/nodes/node_composite_filter.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_filter.cc
@@ -33,7 +33,7 @@ static void cmp_node_filter_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_buts_filter(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_filter(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "filter_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_flip.cc b/source/blender/nodes/composite/nodes/node_composite_flip.cc
index aaa2b565ed2..07c96eb4d22 100644
--- a/source/blender/nodes/composite/nodes/node_composite_flip.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_flip.cc
@@ -31,7 +31,7 @@ static void cmp_node_flip_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_buts_flip(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_flip(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "axis", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_glare.cc b/source/blender/nodes/composite/nodes/node_composite_glare.cc
index 33577d5caf8..4352f519e4c 100644
--- a/source/blender/nodes/composite/nodes/node_composite_glare.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_glare.cc
@@ -22,7 +22,7 @@ static void cmp_node_glare_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_glare(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_glare(bNodeTree * /*ntree*/, bNode *node)
{
NodeGlare *ndg = MEM_cnew<NodeGlare>(__func__);
ndg->quality = 1;
@@ -39,7 +39,7 @@ static void node_composit_init_glare(bNodeTree *UNUSED(ntree), bNode *node)
node->storage = ndg;
}
-static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_glare(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "glare_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
uiItemR(layout, ptr, "quality", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
@@ -105,7 +105,7 @@ void register_node_type_cmp_glare()
cmp_node_type_base(&ntype, CMP_NODE_GLARE, "Glare", NODE_CLASS_OP_FILTER);
ntype.declare = file_ns::cmp_node_glare_declare;
ntype.draw_buttons = file_ns::node_composit_buts_glare;
- node_type_init(&ntype, file_ns::node_composit_init_glare);
+ ntype.initfunc = file_ns::node_composit_init_glare;
node_type_storage(&ntype, "NodeGlare", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc b/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc
index 6333860a19b..2e09e44eddc 100644
--- a/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_huecorrect.cc
@@ -31,7 +31,7 @@ static void cmp_node_huecorrect_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_huecorrect(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_huecorrect(bNodeTree * /*ntree*/, bNode *node)
{
node->storage = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
@@ -106,7 +106,7 @@ void register_node_type_cmp_huecorrect()
cmp_node_type_base(&ntype, CMP_NODE_HUECORRECT, "Hue Correct", NODE_CLASS_OP_COLOR);
ntype.declare = file_ns::cmp_node_huecorrect_declare;
node_type_size(&ntype, 320, 140, 500);
- node_type_init(&ntype, file_ns::node_composit_init_huecorrect);
+ ntype.initfunc = file_ns::node_composit_init_huecorrect;
node_type_storage(&ntype, "CurveMapping", node_free_curves, node_copy_curves);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_id_mask.cc b/source/blender/nodes/composite/nodes/node_composite_id_mask.cc
index ac8456cb931..a71b3f132c0 100644
--- a/source/blender/nodes/composite/nodes/node_composite_id_mask.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_id_mask.cc
@@ -22,7 +22,7 @@ static void cmp_node_idmask_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Alpha"));
}
-static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_id_mask(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "index", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
uiItemR(layout, ptr, "use_antialiasing", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
diff --git a/source/blender/nodes/composite/nodes/node_composite_image.cc b/source/blender/nodes/composite/nodes/node_composite_image.cc
index 4d1eff0b940..322f1eecf91 100644
--- a/source/blender/nodes/composite/nodes/node_composite_image.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_image.cc
@@ -80,7 +80,7 @@ static void cmp_node_image_add_pass_output(bNodeTree *ntree,
const char *passname,
int rres_index,
eNodeSocketDatatype type,
- int UNUSED(is_rlayers),
+ int /*is_rlayers*/,
LinkNodePair *available_sockets,
int *prev_index)
{
@@ -273,8 +273,8 @@ static void cmp_node_rlayer_create_outputs_cb(void *userdata,
Scene *scene,
ViewLayer *view_layer,
const char *name,
- int UNUSED(channels),
- const char *UNUSED(chanid),
+ int /*channels*/,
+ const char * /*chanid*/,
eNodeSocketDatatype type)
{
CreateOutputUserData &data = *(CreateOutputUserData *)userdata;
@@ -426,7 +426,7 @@ static void node_composit_free_image(bNode *node)
MEM_freeN(node->storage);
}
-static void node_composit_copy_image(bNodeTree *UNUSED(dest_ntree),
+static void node_composit_copy_image(bNodeTree * /*dst_ntree*/,
bNode *dest_node,
const bNode *src_node)
{
@@ -660,10 +660,10 @@ void register_node_type_cmp_image()
static bNodeType ntype;
cmp_node_type_base(&ntype, CMP_NODE_IMAGE, "Image", NODE_CLASS_INPUT);
- node_type_init(&ntype, file_ns::node_composit_init_image);
+ ntype.initfunc = file_ns::node_composit_init_image;
node_type_storage(
&ntype, "ImageUser", file_ns::node_composit_free_image, file_ns::node_composit_copy_image);
- node_type_update(&ntype, file_ns::cmp_node_image_update);
+ ntype.updatefunc = file_ns::cmp_node_image_update;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
ntype.labelfunc = node_image_label;
ntype.flag |= NODE_PREVIEW;
@@ -685,7 +685,7 @@ const char *node_cmp_rlayers_sock_to_pass(int sock_index)
}
const char *name = cmp_node_rlayers_out[sock_index].name;
/* Exception for alpha, which is derived from Combined. */
- return (STREQ(name, "Alpha")) ? RE_PASSNAME_COMBINED : name;
+ return STREQ(name, "Alpha") ? RE_PASSNAME_COMBINED : name;
}
namespace blender::nodes::node_composite_render_layer_cc {
@@ -710,7 +710,7 @@ static void node_composit_init_rlayers(const bContext *C, PointerRNA *ptr)
}
}
-static bool node_composit_poll_rlayers(bNodeType *UNUSED(ntype),
+static bool node_composit_poll_rlayers(bNodeType * /*ntype*/,
bNodeTree *ntree,
const char **r_disabled_hint)
{
@@ -749,7 +749,7 @@ static void node_composit_free_rlayers(bNode *node)
}
}
-static void node_composit_copy_rlayers(bNodeTree *UNUSED(dest_ntree),
+static void node_composit_copy_rlayers(bNodeTree * /*dst_ntree*/,
bNode *dest_node,
const bNode *src_node)
{
@@ -797,8 +797,7 @@ static void node_composit_buts_viewlayers(uiLayout *layout, bContext *C, Pointer
PropertyRNA *prop = RNA_struct_find_property(ptr, "layer");
const char *layer_name;
- if (!(RNA_property_enum_identifier(
- C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name))) {
+ if (!RNA_property_enum_identifier(C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name)) {
return;
}
@@ -851,7 +850,7 @@ class RenderLayerOperation : public NodeOperation {
/* Other output passes are not supported for now, so allocate them as invalid. */
for (const bNodeSocket *output : this->node()->output_sockets()) {
- if (!STREQ(output->identifier, "Image") && !STREQ(output->identifier, "Alpha")) {
+ if (!STR_ELEM(output->identifier, "Image", "Alpha")) {
get_result(output->identifier).allocate_invalid();
}
}
@@ -880,8 +879,8 @@ void register_node_type_cmp_rlayers()
ntype.flag |= NODE_PREVIEW;
node_type_storage(
&ntype, nullptr, file_ns::node_composit_free_rlayers, file_ns::node_composit_copy_rlayers);
- node_type_update(&ntype, file_ns::cmp_node_rlayers_update);
- node_type_init(&ntype, node_cmp_rlayers_outputs);
+ ntype.updatefunc = file_ns::cmp_node_rlayers_update;
+ ntype.initfunc = node_cmp_rlayers_outputs;
node_type_size_preset(&ntype, NODE_SIZE_LARGE);
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/composite/nodes/node_composite_inpaint.cc b/source/blender/nodes/composite/nodes/node_composite_inpaint.cc
index f6e46bef299..c26021b16bd 100644
--- a/source/blender/nodes/composite/nodes/node_composite_inpaint.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_inpaint.cc
@@ -22,7 +22,7 @@ static void cmp_node_inpaint_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_buts_inpaint(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_inpaint(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "distance", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_invert.cc b/source/blender/nodes/composite/nodes/node_composite_invert.cc
index 4bfcc7b6b9c..c8787ebb01b 100644
--- a/source/blender/nodes/composite/nodes/node_composite_invert.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_invert.cc
@@ -32,12 +32,12 @@ static void cmp_node_invert_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Color"));
}
-static void node_composit_init_invert(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_invert(bNodeTree * /*ntree*/, bNode *node)
{
node->custom1 |= CMP_CHAN_RGB;
}
-static void node_composit_buts_invert(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_invert(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -96,7 +96,7 @@ void register_node_type_cmp_invert()
cmp_node_type_base(&ntype, CMP_NODE_INVERT, "Invert", NODE_CLASS_OP_COLOR);
ntype.declare = file_ns::cmp_node_invert_declare;
ntype.draw_buttons = file_ns::node_composit_buts_invert;
- node_type_init(&ntype, file_ns::node_composit_init_invert);
+ ntype.initfunc = file_ns::node_composit_init_invert;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/composite/nodes/node_composite_keying.cc b/source/blender/nodes/composite/nodes/node_composite_keying.cc
index 8b584e216cd..b2add06c541 100644
--- a/source/blender/nodes/composite/nodes/node_composite_keying.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_keying.cc
@@ -33,7 +33,7 @@ static void cmp_node_keying_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Edges"));
}
-static void node_composit_init_keying(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_keying(bNodeTree * /*ntree*/, bNode *node)
{
NodeKeyingData *data = MEM_cnew<NodeKeyingData>(__func__);
@@ -47,7 +47,7 @@ static void node_composit_init_keying(bNodeTree *UNUSED(ntree), bNode *node)
node->storage = data;
}
-static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_keying(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
/* bNode *node = (bNode*)ptr->data; */ /* UNUSED */
@@ -95,7 +95,7 @@ void register_node_type_cmp_keying()
cmp_node_type_base(&ntype, CMP_NODE_KEYING, "Keying", NODE_CLASS_MATTE);
ntype.declare = file_ns::cmp_node_keying_declare;
ntype.draw_buttons = file_ns::node_composit_buts_keying;
- node_type_init(&ntype, file_ns::node_composit_init_keying);
+ ntype.initfunc = file_ns::node_composit_init_keying;
node_type_storage(
&ntype, "NodeKeyingData", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_lensdist.cc b/source/blender/nodes/composite/nodes/node_composite_lensdist.cc
index 260fccf66d0..e11ed0fbfb6 100644
--- a/source/blender/nodes/composite/nodes/node_composite_lensdist.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_lensdist.cc
@@ -52,14 +52,14 @@ static void cmp_node_lensdist_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_lensdist(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_lensdist(bNodeTree * /*ntree*/, bNode *node)
{
NodeLensDist *nld = MEM_cnew<NodeLensDist>(__func__);
nld->jit = nld->proj = nld->fit = 0;
node->storage = nld;
}
-static void node_composit_buts_lensdist(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_lensdist(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -250,7 +250,7 @@ void register_node_type_cmp_lensdist()
cmp_node_type_base(&ntype, CMP_NODE_LENSDIST, "Lens Distortion", NODE_CLASS_DISTORT);
ntype.declare = file_ns::cmp_node_lensdist_declare;
ntype.draw_buttons = file_ns::node_composit_buts_lensdist;
- node_type_init(&ntype, file_ns::node_composit_init_lensdist);
+ ntype.initfunc = file_ns::node_composit_init_lensdist;
node_type_storage(
&ntype, "NodeLensDist", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_levels.cc b/source/blender/nodes/composite/nodes/node_composite_levels.cc
index 2f1ebeb79b5..29212c7a76f 100644
--- a/source/blender/nodes/composite/nodes/node_composite_levels.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_levels.cc
@@ -5,9 +5,18 @@
* \ingroup cmpnodes
*/
+#include <cmath>
+
+#include "BLI_assert.h"
+#include "BLI_math_vec_types.hh"
+#include "BLI_math_vector.hh"
+
#include "UI_interface.h"
#include "UI_resources.h"
+#include "IMB_colormanagement.h"
+
+#include "COM_algorithm_parallel_reduction.hh"
#include "COM_node_operation.hh"
#include "node_composite_util.hh"
@@ -18,17 +27,19 @@ namespace blender::nodes::node_composite_levels_cc {
static void cmp_node_levels_declare(NodeDeclarationBuilder &b)
{
- b.add_input<decl::Color>(N_("Image")).default_value({0.0f, 0.0f, 0.0f, 1.0f});
+ b.add_input<decl::Color>(N_("Image"))
+ .default_value({0.0f, 0.0f, 0.0f, 1.0f})
+ .compositor_domain_priority(0);
b.add_output<decl::Float>(N_("Mean"));
b.add_output<decl::Float>(N_("Std Dev"));
}
-static void node_composit_init_view_levels(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_view_levels(bNodeTree * /*ntree*/, bNode *node)
{
node->custom1 = 1; /* All channels. */
}
-static void node_composit_buts_view_levels(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_view_levels(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "channel", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
}
@@ -36,13 +47,140 @@ static void node_composit_buts_view_levels(uiLayout *layout, bContext *UNUSED(C)
using namespace blender::realtime_compositor;
class LevelsOperation : public NodeOperation {
+ private:
+ constexpr static float luminance_coefficients_bt709_[3] = {0.2126f, 0.7152f, 0.0722f};
+
public:
using NodeOperation::NodeOperation;
void execute() override
{
- get_result("Mean").allocate_invalid();
- get_result("Std Dev").allocate_invalid();
+ if (get_input("Image").is_single_value()) {
+ execute_single_value();
+ return;
+ }
+
+ const float mean = compute_mean();
+
+ Result &mean_result = get_result("Mean");
+ if (mean_result.should_compute()) {
+ mean_result.allocate_single_value();
+ mean_result.set_float_value(mean);
+ }
+
+ Result &standard_deviation_result = get_result("Std Dev");
+ if (standard_deviation_result.should_compute()) {
+ const float standard_deviation = compute_standard_deviation(mean);
+ standard_deviation_result.allocate_single_value();
+ standard_deviation_result.set_float_value(standard_deviation);
+ }
+ }
+
+ void execute_single_value()
+ {
+ Result &standard_deviation_result = get_result("Std Dev");
+ if (standard_deviation_result.should_compute()) {
+ standard_deviation_result.allocate_single_value();
+ standard_deviation_result.set_float_value(0.0f);
+ }
+
+ Result &mean_result = get_result("Mean");
+ if (!mean_result.should_compute()) {
+ return;
+ }
+
+ mean_result.allocate_single_value();
+ const float3 input = float3(get_input("Image").get_color_value());
+
+ switch (get_channel()) {
+ case CMP_NODE_LEVLES_RED:
+ mean_result.set_float_value(input.x);
+ break;
+ case CMP_NODE_LEVLES_GREEN:
+ mean_result.set_float_value(input.y);
+ break;
+ case CMP_NODE_LEVLES_BLUE:
+ mean_result.set_float_value(input.z);
+ break;
+ case CMP_NODE_LEVLES_LUMINANCE_BT709:
+ mean_result.set_float_value(math::dot(input, float3(luminance_coefficients_bt709_)));
+ break;
+ case CMP_NODE_LEVLES_LUMINANCE: {
+ float luminance_coefficients[3];
+ IMB_colormanagement_get_luminance_coefficients(luminance_coefficients);
+ mean_result.set_float_value(math::dot(input, float3(luminance_coefficients)));
+ break;
+ }
+ default:
+ BLI_assert_unreachable();
+ break;
+ }
+ }
+
+ float compute_mean()
+ {
+ const Result &input = get_input("Image");
+ return compute_sum() / (input.domain().size.x * input.domain().size.y);
+ }
+
+ float compute_sum()
+ {
+ const Result &input = get_input("Image");
+ switch (get_channel()) {
+ case CMP_NODE_LEVLES_RED:
+ return sum_red(context(), input.texture());
+ case CMP_NODE_LEVLES_GREEN:
+ return sum_green(context(), input.texture());
+ case CMP_NODE_LEVLES_BLUE:
+ return sum_blue(context(), input.texture());
+ case CMP_NODE_LEVLES_LUMINANCE_BT709:
+ return sum_luminance(context(), input.texture(), float3(luminance_coefficients_bt709_));
+ case CMP_NODE_LEVLES_LUMINANCE: {
+ float luminance_coefficients[3];
+ IMB_colormanagement_get_luminance_coefficients(luminance_coefficients);
+ return sum_luminance(context(), input.texture(), float3(luminance_coefficients));
+ }
+ default:
+ BLI_assert_unreachable();
+ return 0.0f;
+ }
+ }
+
+ float compute_standard_deviation(float mean)
+ {
+ const Result &input = get_input("Image");
+ const float sum = compute_sum_squared_difference(mean);
+ return std::sqrt(sum / (input.domain().size.x * input.domain().size.y));
+ }
+
+ float compute_sum_squared_difference(float subtrahend)
+ {
+ const Result &input = get_input("Image");
+ switch (get_channel()) {
+ case CMP_NODE_LEVLES_RED:
+ return sum_red_squared_difference(context(), input.texture(), subtrahend);
+ case CMP_NODE_LEVLES_GREEN:
+ return sum_green_squared_difference(context(), input.texture(), subtrahend);
+ case CMP_NODE_LEVLES_BLUE:
+ return sum_blue_squared_difference(context(), input.texture(), subtrahend);
+ case CMP_NODE_LEVLES_LUMINANCE_BT709:
+ return sum_luminance_squared_difference(
+ context(), input.texture(), float3(luminance_coefficients_bt709_), subtrahend);
+ case CMP_NODE_LEVLES_LUMINANCE: {
+ float luminance_coefficients[3];
+ IMB_colormanagement_get_luminance_coefficients(luminance_coefficients);
+ return sum_luminance_squared_difference(
+ context(), input.texture(), float3(luminance_coefficients), subtrahend);
+ }
+ default:
+ BLI_assert_unreachable();
+ return 0.0f;
+ }
+ }
+
+ CMPNodeLevelsChannel get_channel()
+ {
+ return static_cast<CMPNodeLevelsChannel>(bnode().custom1);
}
};
@@ -63,7 +201,7 @@ void register_node_type_cmp_view_levels()
ntype.declare = file_ns::cmp_node_levels_declare;
ntype.draw_buttons = file_ns::node_composit_buts_view_levels;
ntype.flag |= NODE_PREVIEW;
- node_type_init(&ntype, file_ns::node_composit_init_view_levels);
+ ntype.initfunc = file_ns::node_composit_init_view_levels;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/composite/nodes/node_composite_luma_matte.cc b/source/blender/nodes/composite/nodes/node_composite_luma_matte.cc
index 59ae62ec411..325f5dbd870 100644
--- a/source/blender/nodes/composite/nodes/node_composite_luma_matte.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_luma_matte.cc
@@ -31,7 +31,7 @@ static void cmp_node_luma_matte_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Matte"));
}
-static void node_composit_init_luma_matte(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_luma_matte(bNodeTree * /*ntree*/, bNode *node)
{
NodeChroma *c = MEM_cnew<NodeChroma>(__func__);
node->storage = c;
@@ -39,7 +39,7 @@ static void node_composit_init_luma_matte(bNodeTree *UNUSED(ntree), bNode *node)
c->t2 = 0.0f;
}
-static void node_composit_buts_luma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_luma_matte(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -104,7 +104,7 @@ void register_node_type_cmp_luma_matte()
ntype.declare = file_ns::cmp_node_luma_matte_declare;
ntype.draw_buttons = file_ns::node_composit_buts_luma_matte;
ntype.flag |= NODE_PREVIEW;
- node_type_init(&ntype, file_ns::node_composit_init_luma_matte);
+ ntype.initfunc = file_ns::node_composit_init_luma_matte;
node_type_storage(&ntype, "NodeChroma", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_map_range.cc b/source/blender/nodes/composite/nodes/node_composite_map_range.cc
index e72869efa93..0dace651742 100644
--- a/source/blender/nodes/composite/nodes/node_composite_map_range.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_map_range.cc
@@ -48,7 +48,7 @@ static void cmp_node_map_range_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Value"));
}
-static void node_composit_buts_map_range(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_map_range(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
diff --git a/source/blender/nodes/composite/nodes/node_composite_map_uv.cc b/source/blender/nodes/composite/nodes/node_composite_map_uv.cc
index 4f660d62c3b..86f85ed7031 100644
--- a/source/blender/nodes/composite/nodes/node_composite_map_uv.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_map_uv.cc
@@ -23,7 +23,7 @@ static void cmp_node_map_uv_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_buts_map_uv(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_map_uv(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "alpha", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_map_value.cc b/source/blender/nodes/composite/nodes/node_composite_map_value.cc
index e30de39605d..ea80e7b03a8 100644
--- a/source/blender/nodes/composite/nodes/node_composite_map_value.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_map_value.cc
@@ -34,12 +34,12 @@ static void cmp_node_map_value_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Value"));
}
-static void node_composit_init_map_value(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_map_value(bNodeTree * /*ntree*/, bNode *node)
{
node->storage = BKE_texture_mapping_add(TEXMAP_TYPE_POINT);
}
-static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_map_value(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *sub, *col;
@@ -116,7 +116,7 @@ void register_node_type_cmp_map_value()
cmp_node_type_base(&ntype, CMP_NODE_MAP_VALUE, "Map Value", NODE_CLASS_OP_VECTOR);
ntype.declare = file_ns::cmp_node_map_value_declare;
ntype.draw_buttons = file_ns::node_composit_buts_map_value;
- node_type_init(&ntype, file_ns::node_composit_init_map_value);
+ ntype.initfunc = file_ns::node_composit_init_map_value;
node_type_storage(&ntype, "TexMapping", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_mask.cc b/source/blender/nodes/composite/nodes/node_composite_mask.cc
index 2372dbae3f2..895ef62a82d 100644
--- a/source/blender/nodes/composite/nodes/node_composite_mask.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_mask.cc
@@ -23,7 +23,7 @@ static void cmp_node_mask_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Mask"));
}
-static void node_composit_init_mask(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_mask(bNodeTree * /*ntree*/, bNode *node)
{
NodeMask *data = MEM_cnew<NodeMask>(__func__);
data->size_x = data->size_y = 256;
@@ -33,7 +33,7 @@ static void node_composit_init_mask(bNodeTree *UNUSED(ntree), bNode *node)
node->custom3 = 0.5f; /* shutter */
}
-static void node_mask_label(const bNodeTree *UNUSED(ntree),
+static void node_mask_label(const bNodeTree * /*ntree*/,
const bNode *node,
char *label,
int maxlen)
@@ -104,7 +104,7 @@ void register_node_type_cmp_mask()
cmp_node_type_base(&ntype, CMP_NODE_MASK, "Mask", NODE_CLASS_INPUT);
ntype.declare = file_ns::cmp_node_mask_declare;
ntype.draw_buttons = file_ns::node_composit_buts_mask;
- node_type_init(&ntype, file_ns::node_composit_init_mask);
+ ntype.initfunc = file_ns::node_composit_init_mask;
ntype.labelfunc = file_ns::node_mask_label;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_math.cc b/source/blender/nodes/composite/nodes/node_composite_math.cc
index 4baf057913e..e1dda06a41e 100644
--- a/source/blender/nodes/composite/nodes/node_composite_math.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_math.cc
@@ -96,7 +96,7 @@ void register_node_type_cmp_math()
cmp_node_type_base(&ntype, CMP_NODE_MATH, "Math", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_math_declare;
ntype.labelfunc = node_math_label;
- node_type_update(&ntype, node_math_update);
+ ntype.updatefunc = node_math_update;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.cc b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.cc
index 88638586594..aad6eb3ce5e 100644
--- a/source/blender/nodes/composite/nodes/node_composite_moviedistortion.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_moviedistortion.cc
@@ -26,7 +26,7 @@ static void cmp_node_moviedistortion_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void label(const bNodeTree *UNUSED(ntree), const bNode *node, char *label, int maxlen)
+static void label(const bNodeTree * /*ntree*/, const bNode *node, char *label, int maxlen)
{
if (node->custom1 == 0) {
BLI_strncpy(label, IFACE_("Undistortion"), maxlen);
@@ -54,7 +54,7 @@ static void storage_free(bNode *node)
node->storage = nullptr;
}
-static void storage_copy(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
+static void storage_copy(bNodeTree * /*dst_ntree*/, bNode *dest_node, const bNode *src_node)
{
if (src_node->storage) {
dest_node->storage = BKE_tracking_distortion_copy((MovieDistortion *)src_node->storage);
diff --git a/source/blender/nodes/composite/nodes/node_composite_normalize.cc b/source/blender/nodes/composite/nodes/node_composite_normalize.cc
index 21765825468..34fd63e5805 100644
--- a/source/blender/nodes/composite/nodes/node_composite_normalize.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_normalize.cc
@@ -5,7 +5,9 @@
* \ingroup cmpnodes
*/
+#include "COM_algorithm_parallel_reduction.hh"
#include "COM_node_operation.hh"
+#include "COM_utilities.hh"
#include "node_composite_util.hh"
@@ -15,19 +17,60 @@ namespace blender::nodes::node_composite_normalize_cc {
static void cmp_node_normalize_declare(NodeDeclarationBuilder &b)
{
- b.add_input<decl::Float>(N_("Value")).default_value(1.0f).min(0.0f).max(1.0f);
+ b.add_input<decl::Float>(N_("Value"))
+ .default_value(1.0f)
+ .min(0.0f)
+ .max(1.0f)
+ .compositor_domain_priority(0);
b.add_output<decl::Float>(N_("Value"));
}
using namespace blender::realtime_compositor;
class NormalizeOperation : public NodeOperation {
+ private:
+ /* The normalize operation is specifically designed to normalize Z Depth information. But since Z
+ * Depth can contain near infinite values, normalization is limited to [-range_, range], meaning
+ * that values outside of that range will be ignored when computing the maximum and minimum for
+ * normalization and will eventually be 0 or 1 if they are less than or larger than the range
+ * respectively. */
+ constexpr static float range_ = 10000.0f;
+
public:
using NodeOperation::NodeOperation;
void execute() override
{
- get_input("Value").pass_through(get_result("Value"));
+ Result &input_image = get_input("Value");
+ Result &output_image = get_result("Value");
+ if (input_image.is_single_value()) {
+ input_image.pass_through(output_image);
+ return;
+ }
+
+ const float maximum = maximum_float_in_range(
+ context(), input_image.texture(), -range_, range_);
+ const float minimum = minimum_float_in_range(
+ context(), input_image.texture(), -range_, range_);
+ const float scale = (maximum != minimum) ? (1.0f / (maximum - minimum)) : 0.0f;
+
+ GPUShader *shader = shader_manager().get("compositor_normalize");
+ GPU_shader_bind(shader);
+
+ GPU_shader_uniform_1f(shader, "minimum", minimum);
+ GPU_shader_uniform_1f(shader, "scale", scale);
+
+ input_image.bind_as_texture(shader, "input_tx");
+
+ const Domain domain = compute_domain();
+ output_image.allocate_texture(domain);
+ output_image.bind_as_image(shader, "output_img");
+
+ compute_dispatch_threads_at_least(shader, domain.size);
+
+ GPU_shader_unbind();
+ output_image.unbind_as_image();
+ input_image.unbind_as_texture();
}
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_output_file.cc b/source/blender/nodes/composite/nodes/node_composite_output_file.cc
index 5ed383977a5..f64e448842d 100644
--- a/source/blender/nodes/composite/nodes/node_composite_output_file.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_output_file.cc
@@ -231,9 +231,7 @@ static void free_output_file(bNode *node)
MEM_freeN(node->storage);
}
-static void copy_output_file(bNodeTree *UNUSED(dest_ntree),
- bNode *dest_node,
- const bNode *src_node)
+static void copy_output_file(bNodeTree * /*dst_ntree*/, bNode *dest_node, const bNode *src_node)
{
bNodeSocket *src_sock, *dest_sock;
@@ -282,7 +280,7 @@ static void update_output_file(bNodeTree *ntree, bNode *node)
}
}
-static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_file_output(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
PointerRNA imfptr = RNA_pointer_get(ptr, "format");
const bool multilayer = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER;
@@ -472,7 +470,7 @@ void register_node_type_cmp_output_file()
ntype.flag |= NODE_PREVIEW;
node_type_storage(
&ntype, "NodeImageMultiFile", file_ns::free_output_file, file_ns::copy_output_file);
- node_type_update(&ntype, file_ns::update_output_file);
+ ntype.updatefunc = file_ns::update_output_file;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/composite/nodes/node_composite_pixelate.cc b/source/blender/nodes/composite/nodes/node_composite_pixelate.cc
index c4e42f8247d..c65bb7bb747 100644
--- a/source/blender/nodes/composite/nodes/node_composite_pixelate.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_pixelate.cc
@@ -36,7 +36,10 @@ class PixelateOperation : public NodeOperation {
* matches its apparent size, that is, its size after the domain transformation. The pixelate
* node has no effect if the input is scaled-up. See the compute_domain method for more
* information. */
- get_input("Color").pass_through(get_result("Color"));
+ Result &result = get_result("Color");
+ get_input("Color").pass_through(result);
+
+ result.get_realization_options().interpolation = Interpolation::Nearest;
}
/* Compute a smaller-sized domain that matches the apparent size of the input while having a unit
diff --git a/source/blender/nodes/composite/nodes/node_composite_premulkey.cc b/source/blender/nodes/composite/nodes/node_composite_premulkey.cc
index c814ea5f738..85e37e12231 100644
--- a/source/blender/nodes/composite/nodes/node_composite_premulkey.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_premulkey.cc
@@ -26,7 +26,7 @@ static void cmp_node_premulkey_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_buts_premulkey(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_premulkey(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "mapping", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_rotate.cc b/source/blender/nodes/composite/nodes/node_composite_rotate.cc
index 35caa3cd242..4cc1166b373 100644
--- a/source/blender/nodes/composite/nodes/node_composite_rotate.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_rotate.cc
@@ -33,12 +33,12 @@ static void cmp_node_rotate_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_rotate(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_rotate(bNodeTree * /*ntree*/, bNode *node)
{
node->custom1 = 1; /* Bilinear Filter. */
}
-static void node_composit_buts_rotate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_rotate(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "filter_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
}
@@ -95,7 +95,7 @@ void register_node_type_cmp_rotate()
cmp_node_type_base(&ntype, CMP_NODE_ROTATE, "Rotate", NODE_CLASS_DISTORT);
ntype.declare = file_ns::cmp_node_rotate_declare;
ntype.draw_buttons = file_ns::node_composit_buts_rotate;
- node_type_init(&ntype, file_ns::node_composit_init_rotate);
+ ntype.initfunc = file_ns::node_composit_init_rotate;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/composite/nodes/node_composite_scale.cc b/source/blender/nodes/composite/nodes/node_composite_scale.cc
index eb2d7162c69..a4e28326d9d 100644
--- a/source/blender/nodes/composite/nodes/node_composite_scale.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_scale.cc
@@ -54,7 +54,7 @@ static void node_composite_update_scale(bNodeTree *ntree, bNode *node)
}
}
-static void node_composit_buts_scale(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_scale(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "space", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
@@ -88,7 +88,6 @@ class ScaleOperation : public NodeOperation {
get_translation(), 0.0f, get_scale());
result.transform(transformation);
- result.get_realization_options().interpolation = Interpolation::Bilinear;
}
float2 get_scale()
@@ -222,7 +221,7 @@ void register_node_type_cmp_scale()
cmp_node_type_base(&ntype, CMP_NODE_SCALE, "Scale", NODE_CLASS_DISTORT);
ntype.declare = file_ns::cmp_node_scale_declare;
ntype.draw_buttons = file_ns::node_composit_buts_scale;
- node_type_update(&ntype, file_ns::node_composite_update_scale);
+ ntype.updatefunc = file_ns::node_composite_update_scale;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/composite/nodes/node_composite_scene_time.cc b/source/blender/nodes/composite/nodes/node_composite_scene_time.cc
index 1f5317378bb..3a7e7dc78bd 100644
--- a/source/blender/nodes/composite/nodes/node_composite_scene_time.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_scene_time.cc
@@ -38,7 +38,7 @@ class SceneTimeOperation : public NodeOperation {
{
Result &result = get_result("Frame");
result.allocate_single_value();
- result.set_float_value(static_cast<float>(context().get_frame_number()));
+ result.set_float_value(float(context().get_frame_number()));
}
};
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcomb_color.cc b/source/blender/nodes/composite/nodes/node_composite_sepcomb_color.cc
index f6792d7ce61..118ab6ccdf8 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcomb_color.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcomb_color.cc
@@ -8,7 +8,7 @@
#include "node_composite_util.hh"
-static void node_cmp_combsep_color_init(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_cmp_combsep_color_init(bNodeTree * /*ntree*/, bNode *node)
{
NodeCMPCombSepColor *data = MEM_cnew<NodeCMPCombSepColor>(__func__);
data->mode = CMP_NODE_COMBSEP_COLOR_RGB;
@@ -75,7 +75,7 @@ static void cmp_node_separate_color_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Alpha"));
}
-static void cmp_node_separate_color_update(bNodeTree *UNUSED(ntree), bNode *node)
+static void cmp_node_separate_color_update(bNodeTree * /*ntree*/, bNode *node)
{
const NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)node->storage;
node_cmp_combsep_color_label(&node->outputs, (CMPNodeCombSepColorMode)storage->mode);
@@ -137,10 +137,10 @@ void register_node_type_cmp_separate_color()
cmp_node_type_base(&ntype, CMP_NODE_SEPARATE_COLOR, "Separate Color", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_separate_color_declare;
- node_type_init(&ntype, node_cmp_combsep_color_init);
+ ntype.initfunc = node_cmp_combsep_color_init;
node_type_storage(
&ntype, "NodeCMPCombSepColor", node_free_standard_storage, node_copy_standard_storage);
- node_type_update(&ntype, file_ns::cmp_node_separate_color_update);
+ ntype.updatefunc = file_ns::cmp_node_separate_color_update;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
nodeRegisterType(&ntype);
@@ -181,7 +181,7 @@ static void cmp_node_combine_color_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void cmp_node_combine_color_update(bNodeTree *UNUSED(ntree), bNode *node)
+static void cmp_node_combine_color_update(bNodeTree * /*ntree*/, bNode *node)
{
const NodeCMPCombSepColor *storage = (NodeCMPCombSepColor *)node->storage;
node_cmp_combsep_color_label(&node->inputs, (CMPNodeCombSepColorMode)storage->mode);
@@ -243,10 +243,10 @@ void register_node_type_cmp_combine_color()
cmp_node_type_base(&ntype, CMP_NODE_COMBINE_COLOR, "Combine Color", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_combine_color_declare;
- node_type_init(&ntype, node_cmp_combsep_color_init);
+ ntype.initfunc = node_cmp_combsep_color_init;
node_type_storage(
&ntype, "NodeCMPCombSepColor", node_free_standard_storage, node_copy_standard_storage);
- node_type_update(&ntype, file_ns::cmp_node_combine_color_update);
+ ntype.updatefunc = file_ns::cmp_node_combine_color_update;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcomb_hsva.cc b/source/blender/nodes/composite/nodes/node_composite_sepcomb_hsva.cc
index b655c0db106..3483285793a 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcomb_hsva.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcomb_hsva.cc
@@ -54,7 +54,8 @@ void register_node_type_cmp_sephsva()
static bNodeType ntype;
- cmp_node_type_base(&ntype, CMP_NODE_SEPHSVA_LEGACY, "Separate HSVA", NODE_CLASS_CONVERTER);
+ cmp_node_type_base(
+ &ntype, CMP_NODE_SEPHSVA_LEGACY, "Separate HSVA (Legacy)", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_sephsva_declare;
ntype.gather_link_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
@@ -107,7 +108,8 @@ void register_node_type_cmp_combhsva()
static bNodeType ntype;
- cmp_node_type_base(&ntype, CMP_NODE_COMBHSVA_LEGACY, "Combine HSVA", NODE_CLASS_CONVERTER);
+ cmp_node_type_base(
+ &ntype, CMP_NODE_COMBHSVA_LEGACY, "Combine HSVA (Legacy)", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_combhsva_declare;
ntype.gather_link_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcomb_rgba.cc b/source/blender/nodes/composite/nodes/node_composite_sepcomb_rgba.cc
index 1f4c9fd153f..9308052454d 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcomb_rgba.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcomb_rgba.cc
@@ -54,7 +54,8 @@ void register_node_type_cmp_seprgba()
static bNodeType ntype;
- cmp_node_type_base(&ntype, CMP_NODE_SEPRGBA_LEGACY, "Separate RGBA", NODE_CLASS_CONVERTER);
+ cmp_node_type_base(
+ &ntype, CMP_NODE_SEPRGBA_LEGACY, "Separate RGBA (Legacy)", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_seprgba_declare;
ntype.gather_link_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
@@ -107,7 +108,8 @@ void register_node_type_cmp_combrgba()
static bNodeType ntype;
- cmp_node_type_base(&ntype, CMP_NODE_COMBRGBA_LEGACY, "Combine RGBA", NODE_CLASS_CONVERTER);
+ cmp_node_type_base(
+ &ntype, CMP_NODE_COMBRGBA_LEGACY, "Combine RGBA (Legacy)", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_combrgba_declare;
ntype.gather_link_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcomb_ycca.cc b/source/blender/nodes/composite/nodes/node_composite_sepcomb_ycca.cc
index bebe6abe115..7c1461b4f6e 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcomb_ycca.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcomb_ycca.cc
@@ -28,7 +28,7 @@ static void cmp_node_sepycca_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("A"));
}
-static void node_composit_init_mode_sepycca(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_mode_sepycca(bNodeTree * /*ntree*/, bNode *node)
{
node->custom1 = 1; /* BLI_YCC_ITU_BT709 */
}
@@ -81,9 +81,10 @@ void register_node_type_cmp_sepycca()
static bNodeType ntype;
- cmp_node_type_base(&ntype, CMP_NODE_SEPYCCA_LEGACY, "Separate YCbCrA", NODE_CLASS_CONVERTER);
+ cmp_node_type_base(
+ &ntype, CMP_NODE_SEPYCCA_LEGACY, "Separate YCbCrA (Legacy)", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_sepycca_declare;
- node_type_init(&ntype, file_ns::node_composit_init_mode_sepycca);
+ ntype.initfunc = file_ns::node_composit_init_mode_sepycca;
ntype.gather_link_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
@@ -115,7 +116,7 @@ static void cmp_node_combycca_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_mode_combycca(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_mode_combycca(bNodeTree * /*ntree*/, bNode *node)
{
node->custom1 = 1; /* BLI_YCC_ITU_BT709 */
}
@@ -168,9 +169,10 @@ void register_node_type_cmp_combycca()
static bNodeType ntype;
- cmp_node_type_base(&ntype, CMP_NODE_COMBYCCA_LEGACY, "Combine YCbCrA", NODE_CLASS_CONVERTER);
+ cmp_node_type_base(
+ &ntype, CMP_NODE_COMBYCCA_LEGACY, "Combine YCbCrA (Legacy)", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_combycca_declare;
- node_type_init(&ntype, file_ns::node_composit_init_mode_combycca);
+ ntype.initfunc = file_ns::node_composit_init_mode_combycca;
ntype.gather_link_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_sepcomb_yuva.cc b/source/blender/nodes/composite/nodes/node_composite_sepcomb_yuva.cc
index 1f0eb04cfc3..b12e70ad9b8 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sepcomb_yuva.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_sepcomb_yuva.cc
@@ -54,7 +54,8 @@ void register_node_type_cmp_sepyuva()
static bNodeType ntype;
- cmp_node_type_base(&ntype, CMP_NODE_SEPYUVA_LEGACY, "Separate YUVA", NODE_CLASS_CONVERTER);
+ cmp_node_type_base(
+ &ntype, CMP_NODE_SEPYUVA_LEGACY, "Separate YUVA (Legacy)", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_sepyuva_declare;
ntype.gather_link_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
@@ -107,7 +108,8 @@ void register_node_type_cmp_combyuva()
static bNodeType ntype;
- cmp_node_type_base(&ntype, CMP_NODE_COMBYUVA_LEGACY, "Combine YUVA", NODE_CLASS_CONVERTER);
+ cmp_node_type_base(
+ &ntype, CMP_NODE_COMBYUVA_LEGACY, "Combine YUVA (Legacy)", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_combyuva_declare;
ntype.gather_link_search_ops = nullptr;
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_setalpha.cc b/source/blender/nodes/composite/nodes/node_composite_setalpha.cc
index df3aca2c665..99c4dae4a92 100644
--- a/source/blender/nodes/composite/nodes/node_composite_setalpha.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_setalpha.cc
@@ -33,14 +33,14 @@ static void cmp_node_setalpha_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_setalpha(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_setalpha(bNodeTree * /*ntree*/, bNode *node)
{
NodeSetAlpha *settings = MEM_cnew<NodeSetAlpha>(__func__);
node->storage = settings;
settings->mode = CMP_NODE_SETALPHA_MODE_APPLY;
}
-static void node_composit_buts_set_alpha(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_set_alpha(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "mode", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
}
@@ -81,7 +81,7 @@ void register_node_type_cmp_setalpha()
cmp_node_type_base(&ntype, CMP_NODE_SETALPHA, "Set Alpha", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_setalpha_declare;
ntype.draw_buttons = file_ns::node_composit_buts_set_alpha;
- node_type_init(&ntype, file_ns::node_composit_init_setalpha);
+ ntype.initfunc = file_ns::node_composit_init_setalpha;
node_type_storage(
&ntype, "NodeSetAlpha", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_split_viewer.cc b/source/blender/nodes/composite/nodes/node_composite_split_viewer.cc
index 085de69e63e..b4e698f5096 100644
--- a/source/blender/nodes/composite/nodes/node_composite_split_viewer.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_split_viewer.cc
@@ -29,7 +29,7 @@ static void cmp_node_split_viewer_declare(NodeDeclarationBuilder &b)
b.add_input<decl::Color>(N_("Image"), "Image_001");
}
-static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_splitviewer(bNodeTree * /*ntree*/, bNode *node)
{
ImageUser *iuser = MEM_cnew<ImageUser>(__func__);
node->storage = iuser;
@@ -39,7 +39,7 @@ static void node_composit_init_splitviewer(bNodeTree *UNUSED(ntree), bNode *node
node->id = (ID *)BKE_image_ensure_viewer(G.main, IMA_TYPE_COMPOSITE, "Viewer Node");
}
-static void node_composit_buts_splitviewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_splitviewer(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *row, *col;
@@ -125,7 +125,7 @@ void register_node_type_cmp_splitviewer()
ntype.declare = file_ns::cmp_node_split_viewer_declare;
ntype.draw_buttons = file_ns::node_composit_buts_splitviewer;
ntype.flag |= NODE_PREVIEW;
- node_type_init(&ntype, file_ns::node_composit_init_splitviewer);
+ ntype.initfunc = file_ns::node_composit_init_splitviewer;
node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_sunbeams.cc b/source/blender/nodes/composite/nodes/node_composite_sunbeams.cc
index 4b9264d7e35..798e60e9482 100644
--- a/source/blender/nodes/composite/nodes/node_composite_sunbeams.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_sunbeams.cc
@@ -20,7 +20,7 @@ static void cmp_node_sunbeams_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void init(bNodeTree *UNUSED(ntree), bNode *node)
+static void init(bNodeTree * /*ntree*/, bNode *node)
{
NodeSunBeams *data = MEM_cnew<NodeSunBeams>(__func__);
@@ -29,7 +29,7 @@ static void init(bNodeTree *UNUSED(ntree), bNode *node)
node->storage = data;
}
-static void node_composit_buts_sunbeams(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_sunbeams(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "source", UI_ITEM_R_SPLIT_EMPTY_NAME | UI_ITEM_R_EXPAND, "", ICON_NONE);
uiItemR(layout,
@@ -68,7 +68,7 @@ void register_node_type_cmp_sunbeams()
cmp_node_type_base(&ntype, CMP_NODE_SUNBEAMS, "Sun Beams", NODE_CLASS_OP_FILTER);
ntype.declare = file_ns::cmp_node_sunbeams_declare;
ntype.draw_buttons = file_ns::node_composit_buts_sunbeams;
- node_type_init(&ntype, file_ns::init);
+ ntype.initfunc = file_ns::init;
node_type_storage(
&ntype, "NodeSunBeams", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_switch.cc b/source/blender/nodes/composite/nodes/node_composite_switch.cc
index 767802cc442..c62ae652029 100644
--- a/source/blender/nodes/composite/nodes/node_composite_switch.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_switch.cc
@@ -23,7 +23,7 @@ static void cmp_node_switch_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_buts_switch(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_switch(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "check", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_switchview.cc b/source/blender/nodes/composite/nodes/node_composite_switchview.cc
index e74c3b6007a..9974e55cc1a 100644
--- a/source/blender/nodes/composite/nodes/node_composite_switchview.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_switchview.cc
@@ -129,8 +129,8 @@ static void init_switch_view(const bContext *C, PointerRNA *ptr)
}
static void node_composit_buts_switch_view_ex(uiLayout *layout,
- bContext *UNUSED(C),
- PointerRNA *UNUSED(ptr))
+ bContext * /*C*/,
+ PointerRNA * /*ptr*/)
{
uiItemFullO(layout,
"NODE_OT_switch_view_update",
@@ -173,7 +173,7 @@ void register_node_type_cmp_switch_view()
node_type_socket_templates(&ntype, nullptr, file_ns::cmp_node_switch_view_out);
ntype.draw_buttons_ex = file_ns::node_composit_buts_switch_view_ex;
ntype.initfunc_api = file_ns::init_switch_view;
- node_type_update(&ntype, file_ns::cmp_node_switch_view_update);
+ ntype.updatefunc = file_ns::cmp_node_switch_view_update;
ntype.get_compositor_operation = file_ns::get_compositor_operation;
nodeRegisterType(&ntype);
diff --git a/source/blender/nodes/composite/nodes/node_composite_tonemap.cc b/source/blender/nodes/composite/nodes/node_composite_tonemap.cc
index 4cc3d4f32a3..febbb9ddec5 100644
--- a/source/blender/nodes/composite/nodes/node_composite_tonemap.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_tonemap.cc
@@ -5,24 +5,39 @@
* \ingroup cmpnodes
*/
+#include <cmath>
+
+#include "BLI_assert.h"
+#include "BLI_math_base.hh"
+#include "BLI_math_vec_types.hh"
+#include "BLI_math_vector.hh"
+
#include "RNA_access.h"
#include "UI_interface.h"
#include "UI_resources.h"
+#include "IMB_colormanagement.h"
+
+#include "COM_algorithm_parallel_reduction.hh"
#include "COM_node_operation.hh"
+#include "COM_utilities.hh"
#include "node_composite_util.hh"
namespace blender::nodes::node_composite_tonemap_cc {
+NODE_STORAGE_FUNCS(NodeTonemap)
+
static void cmp_node_tonemap_declare(NodeDeclarationBuilder &b)
{
- b.add_input<decl::Color>(N_("Image")).default_value({1.0f, 1.0f, 1.0f, 1.0f});
+ b.add_input<decl::Color>(N_("Image"))
+ .default_value({1.0f, 1.0f, 1.0f, 1.0f})
+ .compositor_domain_priority(0);
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_tonemap(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_tonemap(bNodeTree * /*ntree*/, bNode *node)
{
NodeTonemap *ntm = MEM_cnew<NodeTonemap>(__func__);
ntm->type = 1;
@@ -38,7 +53,7 @@ static void node_composit_init_tonemap(bNodeTree *UNUSED(ntree), bNode *node)
node->storage = ntm;
}
-static void node_composit_buts_tonemap(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_tonemap(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -68,7 +83,236 @@ class ToneMapOperation : public NodeOperation {
void execute() override
{
- get_input("Image").pass_through(get_result("Image"));
+ Result &input_image = get_input("Image");
+ Result &output_image = get_result("Image");
+ if (input_image.is_single_value()) {
+ input_image.pass_through(output_image);
+ return;
+ }
+
+ switch (get_type()) {
+ case CMP_NODE_TONE_MAP_SIMPLE:
+ execute_simple();
+ return;
+ case CMP_NODE_TONE_MAP_PHOTORECEPTOR:
+ execute_photoreceptor();
+ return;
+ default:
+ BLI_assert_unreachable();
+ return;
+ }
+ }
+
+ /* Tone mapping based on equation (3) from Reinhard, Erik, et al. "Photographic tone reproduction
+ * for digital images." Proceedings of the 29th annual conference on Computer graphics and
+ * interactive techniques. 2002. */
+ void execute_simple()
+ {
+ const float luminance_scale = compute_luminance_scale();
+ const float luminance_scale_blend_factor = compute_luminance_scale_blend_factor();
+ const float gamma = node_storage(bnode()).gamma;
+ const float inverse_gamma = gamma != 0.0f ? 1.0f / gamma : 0.0f;
+
+ GPUShader *shader = shader_manager().get("compositor_tone_map_simple");
+ GPU_shader_bind(shader);
+
+ GPU_shader_uniform_1f(shader, "luminance_scale", luminance_scale);
+ GPU_shader_uniform_1f(shader, "luminance_scale_blend_factor", luminance_scale_blend_factor);
+ GPU_shader_uniform_1f(shader, "inverse_gamma", inverse_gamma);
+
+ const Result &input_image = get_input("Image");
+ input_image.bind_as_texture(shader, "input_tx");
+
+ const Domain domain = compute_domain();
+ Result &output_image = get_result("Image");
+ output_image.allocate_texture(domain);
+ output_image.bind_as_image(shader, "output_img");
+
+ compute_dispatch_threads_at_least(shader, domain.size);
+
+ GPU_shader_unbind();
+ output_image.unbind_as_image();
+ input_image.unbind_as_texture();
+ }
+
+ /* Computes the scaling factor in equation (2) from Reinhard's 2002 paper. */
+ float compute_luminance_scale()
+ {
+ const float geometric_mean = compute_geometric_mean_of_luminance();
+ return geometric_mean != 0.0 ? node_storage(bnode()).key / geometric_mean : 0.0f;
+ }
+
+ /* Computes equation (1) from Reinhard's 2002 paper. However, note that the equation in the paper
+ * is most likely wrong, and the intention is actually to compute the geometric mean through a
+ * logscale arithmetic mean, that is, the division should happen inside the exponential function,
+ * not outside of it. That's because the sum of the log luminance will be a very large negative
+ * number, whose exponential will almost always be zero, which is unexpected and useless. */
+ float compute_geometric_mean_of_luminance()
+ {
+ return std::exp(compute_average_log_luminance());
+ }
+
+ /* Equation (3) from Reinhard's 2002 paper blends between high luminance scaling for high
+ * luminance values and low luminance scaling for low luminance values. This is done by adding 1
+ * to the denominator, since for low luminance values, the denominator will be close to 1 and for
+ * high luminance values, the 1 in the denominator will be relatively insignificant. But the
+ * response of such function is not always ideal, so in this implementation, the 1 was exposed as
+ * a parameter to the user for more flexibility. */
+ float compute_luminance_scale_blend_factor()
+ {
+ return node_storage(bnode()).offset;
+ }
+
+ /* Tone mapping based on equation (1) and the trilinear interpolation between equations (6) and
+ * (7) from Reinhard, Erik, and Kate Devlin. "Dynamic range reduction inspired by photoreceptor
+ * physiology." IEEE transactions on visualization and computer graphics 11.1 (2005): 13-24. */
+ void execute_photoreceptor()
+ {
+ const float4 global_adaptation_level = compute_global_adaptation_level();
+ const float contrast = compute_contrast();
+ const float intensity = compute_intensity();
+ const float chromatic_adaptation = get_chromatic_adaptation();
+ const float light_adaptation = get_light_adaptation();
+
+ GPUShader *shader = shader_manager().get("compositor_tone_map_photoreceptor");
+ GPU_shader_bind(shader);
+
+ GPU_shader_uniform_4fv(shader, "global_adaptation_level", global_adaptation_level);
+ GPU_shader_uniform_1f(shader, "contrast", contrast);
+ GPU_shader_uniform_1f(shader, "intensity", intensity);
+ GPU_shader_uniform_1f(shader, "chromatic_adaptation", chromatic_adaptation);
+ GPU_shader_uniform_1f(shader, "light_adaptation", light_adaptation);
+
+ float luminance_coefficients[3];
+ IMB_colormanagement_get_luminance_coefficients(luminance_coefficients);
+ GPU_shader_uniform_3fv(shader, "luminance_coefficients", luminance_coefficients);
+
+ const Result &input_image = get_input("Image");
+ input_image.bind_as_texture(shader, "input_tx");
+
+ const Domain domain = compute_domain();
+ Result &output_image = get_result("Image");
+ output_image.allocate_texture(domain);
+ output_image.bind_as_image(shader, "output_img");
+
+ compute_dispatch_threads_at_least(shader, domain.size);
+
+ GPU_shader_unbind();
+ output_image.unbind_as_image();
+ input_image.unbind_as_texture();
+ }
+
+ /* Computes the global adaptation level from the trilinear interpolation equations constructed
+ * from equations (6) and (7) in Reinhard's 2005 paper. */
+ float4 compute_global_adaptation_level()
+ {
+ const float4 average_color = compute_average_color();
+ const float average_luminance = compute_average_luminance();
+ const float chromatic_adaptation = get_chromatic_adaptation();
+ return math::interpolate(float4(average_luminance), average_color, chromatic_adaptation);
+ }
+
+ float4 compute_average_color()
+ {
+ /* The average color will reduce to zero if chromatic adaptation is zero, so just return zero
+ * in this case to avoid needlessly computing the average. See the trilinear interpolation
+ * equations constructed from equations (6) and (7) in Reinhard's 2005 paper. */
+ if (get_chromatic_adaptation() == 0.0f) {
+ return float4(0.0f);
+ }
+
+ const Result &input = get_input("Image");
+ return sum_color(context(), input.texture()) / (input.domain().size.x * input.domain().size.y);
+ }
+
+ float compute_average_luminance()
+ {
+ /* The average luminance will reduce to zero if chromatic adaptation is one, so just return
+ * zero in this case to avoid needlessly computing the average. See the trilinear interpolation
+ * equations constructed from equations (6) and (7) in Reinhard's 2005 paper. */
+ if (get_chromatic_adaptation() == 1.0f) {
+ return 0.0f;
+ }
+
+ float luminance_coefficients[3];
+ IMB_colormanagement_get_luminance_coefficients(luminance_coefficients);
+ const Result &input = get_input("Image");
+ float sum = sum_luminance(context(), input.texture(), luminance_coefficients);
+ return sum / (input.domain().size.x * input.domain().size.y);
+ }
+
+ /* Computes equation (5) from Reinhard's 2005 paper. */
+ float compute_intensity()
+ {
+ return std::exp(-node_storage(bnode()).f);
+ }
+
+ /* If the contrast is not zero, return it, otherwise, a zero contrast denote automatic derivation
+ * of the contrast value based on equations (2) and (4) from Reinhard's 2005 paper. */
+ float compute_contrast()
+ {
+ if (node_storage(bnode()).m != 0.0f) {
+ return node_storage(bnode()).m;
+ }
+
+ const float log_maximum_luminance = compute_log_maximum_luminance();
+ const float log_minimum_luminance = compute_log_minimum_luminance();
+
+ /* This is merely to guard against zero division later. */
+ if (log_maximum_luminance == log_minimum_luminance) {
+ return 1.0f;
+ }
+
+ const float average_log_luminance = compute_average_log_luminance();
+ const float dynamic_range = log_maximum_luminance - log_minimum_luminance;
+ const float luminance_key = (log_maximum_luminance - average_log_luminance) / (dynamic_range);
+
+ return 0.3f + 0.7f * std::pow(luminance_key, 1.4f);
+ }
+
+ float compute_average_log_luminance()
+ {
+ const Result &input_image = get_input("Image");
+
+ float luminance_coefficients[3];
+ IMB_colormanagement_get_luminance_coefficients(luminance_coefficients);
+ const float sum_of_log_luminance = sum_log_luminance(
+ context(), input_image.texture(), luminance_coefficients);
+
+ return sum_of_log_luminance / (input_image.domain().size.x * input_image.domain().size.y);
+ }
+
+ float compute_log_maximum_luminance()
+ {
+ float luminance_coefficients[3];
+ IMB_colormanagement_get_luminance_coefficients(luminance_coefficients);
+ const float maximum = maximum_luminance(
+ context(), get_input("Image").texture(), luminance_coefficients);
+ return std::log(math::max(maximum, 1e-5f));
+ }
+
+ float compute_log_minimum_luminance()
+ {
+ float luminance_coefficients[3];
+ IMB_colormanagement_get_luminance_coefficients(luminance_coefficients);
+ const float minimum = minimum_luminance(
+ context(), get_input("Image").texture(), luminance_coefficients);
+ return std::log(math::max(minimum, 1e-5f));
+ }
+
+ float get_chromatic_adaptation()
+ {
+ return node_storage(bnode()).c;
+ }
+
+ float get_light_adaptation()
+ {
+ return node_storage(bnode()).a;
+ }
+
+ CMPNodeToneMapType get_type()
+ {
+ return static_cast<CMPNodeToneMapType>(node_storage(bnode()).type);
}
};
@@ -88,7 +332,7 @@ void register_node_type_cmp_tonemap()
cmp_node_type_base(&ntype, CMP_NODE_TONEMAP, "Tonemap", NODE_CLASS_OP_COLOR);
ntype.declare = file_ns::cmp_node_tonemap_declare;
ntype.draw_buttons = file_ns::node_composit_buts_tonemap;
- node_type_init(&ntype, file_ns::node_composit_init_tonemap);
+ ntype.initfunc = file_ns::node_composit_init_tonemap;
node_type_storage(&ntype, "NodeTonemap", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_transform.cc b/source/blender/nodes/composite/nodes/node_composite_transform.cc
index 7c5866d2d06..0eaa860b45f 100644
--- a/source/blender/nodes/composite/nodes/node_composite_transform.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_transform.cc
@@ -49,7 +49,7 @@ static void cmp_node_transform_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_buts_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_transform(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "filter_type", UI_ITEM_R_SPLIT_EMPTY_NAME, "", ICON_NONE);
}
diff --git a/source/blender/nodes/composite/nodes/node_composite_translate.cc b/source/blender/nodes/composite/nodes/node_composite_translate.cc
index e0f87ff604a..154be2d428a 100644
--- a/source/blender/nodes/composite/nodes/node_composite_translate.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_translate.cc
@@ -39,13 +39,13 @@ static void cmp_node_translate_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Color>(N_("Image"));
}
-static void node_composit_init_translate(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_translate(bNodeTree * /*ntree*/, bNode *node)
{
NodeTranslateData *data = MEM_cnew<NodeTranslateData>(__func__);
node->storage = data;
}
-static void node_composit_buts_translate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_translate(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "use_relative", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
uiItemR(layout, ptr, "wrap_axis", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
@@ -110,7 +110,7 @@ void register_node_type_cmp_translate()
cmp_node_type_base(&ntype, CMP_NODE_TRANSLATE, "Translate", NODE_CLASS_DISTORT);
ntype.declare = file_ns::cmp_node_translate_declare;
ntype.draw_buttons = file_ns::node_composit_buts_translate;
- node_type_init(&ntype, file_ns::node_composit_init_translate);
+ ntype.initfunc = file_ns::node_composit_init_translate;
node_type_storage(
&ntype, "NodeTranslateData", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc b/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc
index 03a7bc61924..d083051e9d2 100644
--- a/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_val_to_rgb.cc
@@ -35,7 +35,7 @@ static void cmp_node_valtorgb_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Alpha"));
}
-static void node_composit_init_valtorgb(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_valtorgb(bNodeTree * /*ntree*/, bNode *node)
{
node->storage = BKE_colorband_add(true);
}
@@ -134,7 +134,7 @@ void register_node_type_cmp_valtorgb()
cmp_node_type_base(&ntype, CMP_NODE_VALTORGB, "ColorRamp", NODE_CLASS_CONVERTER);
ntype.declare = file_ns::cmp_node_valtorgb_declare;
node_type_size(&ntype, 240, 200, 320);
- node_type_init(&ntype, file_ns::node_composit_init_valtorgb);
+ ntype.initfunc = file_ns::node_composit_init_valtorgb;
node_type_storage(&ntype, "ColorBand", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_shader_node = file_ns::get_compositor_shader_node;
diff --git a/source/blender/nodes/composite/nodes/node_composite_vec_blur.cc b/source/blender/nodes/composite/nodes/node_composite_vec_blur.cc
index 515478da75d..6a44fcb1650 100644
--- a/source/blender/nodes/composite/nodes/node_composite_vec_blur.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_vec_blur.cc
@@ -29,7 +29,7 @@ static void cmp_node_vec_blur_declare(NodeDeclarationBuilder &b)
}
/* custom1: iterations, custom2: max_speed (0 = no_limit). */
-static void node_composit_init_vecblur(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_vecblur(bNodeTree * /*ntree*/, bNode *node)
{
NodeBlurData *nbd = MEM_cnew<NodeBlurData>(__func__);
node->storage = nbd;
@@ -37,7 +37,7 @@ static void node_composit_init_vecblur(bNodeTree *UNUSED(ntree), bNode *node)
nbd->fac = 1.0f;
}
-static void node_composit_buts_vecblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_vecblur(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -81,7 +81,7 @@ void register_node_type_cmp_vecblur()
cmp_node_type_base(&ntype, CMP_NODE_VECBLUR, "Vector Blur", NODE_CLASS_OP_FILTER);
ntype.declare = file_ns::cmp_node_vec_blur_declare;
ntype.draw_buttons = file_ns::node_composit_buts_vecblur;
- node_type_init(&ntype, file_ns::node_composit_init_vecblur);
+ ntype.initfunc = file_ns::node_composit_init_vecblur;
node_type_storage(
&ntype, "NodeBlurData", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_viewer.cc b/source/blender/nodes/composite/nodes/node_composite_viewer.cc
index 4e82b31ca47..682b0626ccd 100644
--- a/source/blender/nodes/composite/nodes/node_composite_viewer.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_viewer.cc
@@ -35,7 +35,7 @@ static void cmp_node_viewer_declare(NodeDeclarationBuilder &b)
b.add_input<decl::Float>(N_("Z")).default_value(1.0f).min(0.0f).max(1.0f);
}
-static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode *node)
+static void node_composit_init_viewer(bNodeTree * /*ntree*/, bNode *node)
{
ImageUser *iuser = MEM_cnew<ImageUser>(__func__);
node->storage = iuser;
@@ -46,12 +46,12 @@ static void node_composit_init_viewer(bNodeTree *UNUSED(ntree), bNode *node)
node->id = (ID *)BKE_image_ensure_viewer(G.main, IMA_TYPE_COMPOSITE, "Viewer Node");
}
-static void node_composit_buts_viewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_viewer(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiItemR(layout, ptr, "use_alpha", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
}
-static void node_composit_buts_viewer_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_viewer_ex(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;
@@ -196,7 +196,7 @@ void register_node_type_cmp_viewer()
ntype.draw_buttons = file_ns::node_composit_buts_viewer;
ntype.draw_buttons_ex = file_ns::node_composit_buts_viewer_ex;
ntype.flag |= NODE_PREVIEW;
- node_type_init(&ntype, file_ns::node_composit_init_viewer);
+ ntype.initfunc = file_ns::node_composit_init_viewer;
node_type_storage(&ntype, "ImageUser", node_free_standard_storage, node_copy_standard_storage);
ntype.get_compositor_operation = file_ns::get_compositor_operation;
diff --git a/source/blender/nodes/composite/nodes/node_composite_zcombine.cc b/source/blender/nodes/composite/nodes/node_composite_zcombine.cc
index e5f460099e9..c1d9442e9ad 100644
--- a/source/blender/nodes/composite/nodes/node_composite_zcombine.cc
+++ b/source/blender/nodes/composite/nodes/node_composite_zcombine.cc
@@ -26,7 +26,7 @@ static void cmp_node_zcombine_declare(NodeDeclarationBuilder &b)
b.add_output<decl::Float>(N_("Z"));
}
-static void node_composit_buts_zcombine(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_composit_buts_zcombine(uiLayout *layout, bContext * /*C*/, PointerRNA *ptr)
{
uiLayout *col;