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:
authorJeroen Bakker <jeroen@blender.org>2022-01-10 10:57:53 +0300
committerJeroen Bakker <jeroen@blender.org>2022-01-10 10:59:00 +0300
commit6beaa297918b24de00d26886e981312b041748b0 (patch)
treec81515e9f1c9e65dbb789e56c1032624db167fca /source/blender/nodes
parenteb7333e772bd9313bf3530eb02e0d036563efe90 (diff)
Compositing Convert color space node
Compositor node to convert between color spaces. Conversion is skipped when converting between the same color spaces or to or from data spaces. Implementation done for tiled and full frame compositor. Reviewed By: Blendify, jbakker Differential Revision: https://developer.blender.org/D12481
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/NOD_composite.h1
-rw-r--r--source/blender/nodes/NOD_static_types.h1
-rw-r--r--source/blender/nodes/composite/CMakeLists.txt1
-rw-r--r--source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc82
4 files changed, 85 insertions, 0 deletions
diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h
index d243577f68d..72539f6081e 100644
--- a/source/blender/nodes/NOD_composite.h
+++ b/source/blender/nodes/NOD_composite.h
@@ -62,6 +62,7 @@ void register_node_type_cmp_alphaover(void);
void register_node_type_cmp_zcombine(void);
void register_node_type_cmp_colorbalance(void);
void register_node_type_cmp_huecorrect(void);
+void register_node_type_cmp_convert_color_space(void);
void register_node_type_cmp_normal(void);
void register_node_type_cmp_curve_vec(void);
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index 74f1531bd90..07a29677b72 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -227,6 +227,7 @@ DefNode(CompositorNode, CMP_NODE_DENOISE, def_cmp_denoise, "DENOIS
DefNode(CompositorNode, CMP_NODE_EXPOSURE, 0, "EXPOSURE", Exposure, "Exposure", "" )
DefNode(CompositorNode, CMP_NODE_ANTIALIASING, def_cmp_antialiasing, "ANTIALIASING", AntiAliasing, "Anti-Aliasing", "" )
DefNode(CompositorNode, CMP_NODE_POSTERIZE, 0, "POSTERIZE", Posterize, "Posterize", "" )
+DefNode(CompositorNode, CMP_NODE_CONVERT_COLOR_SPACE,def_cmp_convert_color_space, "CONVERT_COLORSPACE", ConvertColorSpace, "Color Space","" )
DefNode(TextureNode, TEX_NODE_OUTPUT, def_tex_output, "OUTPUT", Output, "Output", "" )
DefNode(TextureNode, TEX_NODE_CHECKER, 0, "CHECKER", Checker, "Checker", "" )
diff --git a/source/blender/nodes/composite/CMakeLists.txt b/source/blender/nodes/composite/CMakeLists.txt
index 41bcaba22bf..20a7fcc9826 100644
--- a/source/blender/nodes/composite/CMakeLists.txt
+++ b/source/blender/nodes/composite/CMakeLists.txt
@@ -51,6 +51,7 @@ set(SRC
nodes/node_composite_color_spill.cc
nodes/node_composite_colorbalance.cc
nodes/node_composite_colorcorrection.cc
+ nodes/node_composite_convert_color_space.cc
nodes/node_composite_common.cc
nodes/node_composite_composite.cc
nodes/node_composite_cornerpin.cc
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
new file mode 100644
index 00000000000..2aa0b74aa11
--- /dev/null
+++ b/source/blender/nodes/composite/nodes/node_composite_convert_color_space.cc
@@ -0,0 +1,82 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2021 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup cmpnodes
+ */
+
+#include "node_composite_util.hh"
+
+#include "RNA_access.h"
+
+#include "UI_interface.h"
+#include "UI_resources.h"
+
+#include "IMB_colormanagement.h"
+
+namespace blender::nodes {
+
+static void CMP_NODE_CONVERT_COLOR_SPACE_declare(NodeDeclarationBuilder &b)
+{
+ b.add_input<decl::Color>(N_("Image")).default_value({1.0f, 1.0f, 1.0f, 1.0f});
+ b.add_output<decl::Color>(N_("Image"));
+}
+
+} // namespace blender::nodes
+
+static void node_composit_init_convert_colorspace(bNodeTree *UNUSED(ntree), bNode *node)
+{
+ NodeConvertColorSpace *ncs = static_cast<NodeConvertColorSpace *>(
+ MEM_callocN(sizeof(NodeConvertColorSpace), "node colorspace"));
+ const char *first_colorspace = IMB_colormanagement_role_colorspace_name_get(
+ COLOR_ROLE_SCENE_LINEAR);
+ if (first_colorspace && first_colorspace[0]) {
+ STRNCPY(ncs->from_color_space, first_colorspace);
+ STRNCPY(ncs->to_color_space, first_colorspace);
+ }
+ else {
+ ncs->from_color_space[0] = 0;
+ ncs->to_color_space[0] = 0;
+ }
+ node->storage = ncs;
+}
+
+static void node_composit_buts_convert_colorspace(uiLayout *layout,
+ bContext *UNUSED(C),
+ PointerRNA *ptr)
+{
+ uiItemR(layout, ptr, "from_color_space", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
+ uiItemR(layout, ptr, "to_color_space", UI_ITEM_R_SPLIT_EMPTY_NAME, nullptr, ICON_NONE);
+}
+
+void register_node_type_cmp_convert_color_space(void)
+{
+ static bNodeType ntype;
+
+ cmp_node_type_base(
+ &ntype, CMP_NODE_CONVERT_COLOR_SPACE, "Convert Colorspace", NODE_CLASS_CONVERTER);
+ ntype.declare = blender::nodes::CMP_NODE_CONVERT_COLOR_SPACE_declare;
+ ntype.draw_buttons = node_composit_buts_convert_colorspace;
+ node_type_size_preset(&ntype, NODE_SIZE_MIDDLE);
+ node_type_init(&ntype, node_composit_init_convert_colorspace);
+ node_type_storage(
+ &ntype, "NodeConvertColorSpace", node_free_standard_storage, node_copy_standard_storage);
+
+ nodeRegisterType(&ntype);
+}