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:
authorAaron Carlisle <Blendify>2020-12-19 22:40:31 +0300
committerAaron Carlisle <carlisle.b3d@gmail.com>2020-12-19 22:41:14 +0300
commit6538f1e600ad5e0ca04e8e166b848dd321023c4b (patch)
tree503788d9153bbcd79335213877d19e58e03767f2 /source/blender
parent09be4a0917fbdb391341a6bfcc1e918fb75d0fd2 (diff)
Compositor: New Exposure Node
This new node increases the radiance of an image by a scalar value. Previously, the only way to adjust the the exposure of an image was with math node or using the scene's color management. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D9677
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenkernel/BKE_node.h1
-rw-r--r--source/blender/blenkernel/intern/node.c1
-rw-r--r--source/blender/compositor/CMakeLists.txt4
-rw-r--r--source/blender/compositor/intern/COM_Converter.cpp4
-rw-r--r--source/blender/compositor/nodes/COM_ColorExposureNode.cpp37
-rw-r--r--source/blender/compositor/nodes/COM_ColorExposureNode.h34
-rw-r--r--source/blender/compositor/operations/COM_ColorExposureOperation.cpp57
-rw-r--r--source/blender/compositor/operations/COM_ColorExposureOperation.h49
-rw-r--r--source/blender/makesrna/RNA_access.h1
-rw-r--r--source/blender/nodes/CMakeLists.txt1
-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/nodes/node_composite_exposure.c46
13 files changed, 237 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_node.h b/source/blender/blenkernel/BKE_node.h
index bc254b81afb..e18f46c9988 100644
--- a/source/blender/blenkernel/BKE_node.h
+++ b/source/blender/blenkernel/BKE_node.h
@@ -1204,6 +1204,7 @@ void ntreeGPUMaterialNodes(struct bNodeTree *localtree,
#define CMP_NODE_SWITCH_VIEW 322
#define CMP_NODE_CRYPTOMATTE 323
#define CMP_NODE_DENOISE 324
+#define CMP_NODE_EXPOSURE 325
/* channel toggles */
#define CMP_CHAN_RGB 1
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 511c16e9ff4..676d0bf9385 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -4496,6 +4496,7 @@ static void registerCompositNodes(void)
register_node_type_cmp_hue_sat();
register_node_type_cmp_brightcontrast();
register_node_type_cmp_gamma();
+ register_node_type_cmp_exposure();
register_node_type_cmp_invert();
register_node_type_cmp_alphaover();
register_node_type_cmp_zcombine();
diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt
index fec98f58261..26d29f72efb 100644
--- a/source/blender/compositor/CMakeLists.txt
+++ b/source/blender/compositor/CMakeLists.txt
@@ -213,6 +213,8 @@ set(SRC
nodes/COM_ColorCorrectionNode.h
nodes/COM_ColorCurveNode.cpp
nodes/COM_ColorCurveNode.h
+ nodes/COM_ColorExposureNode.cpp
+ nodes/COM_ColorExposureNode.h
nodes/COM_ColorRampNode.cpp
nodes/COM_ColorRampNode.h
nodes/COM_ColorToBWNode.cpp
@@ -399,6 +401,8 @@ set(SRC
operations/COM_ChromaMatteOperation.h
operations/COM_ColorCurveOperation.cpp
operations/COM_ColorCurveOperation.h
+ operations/COM_ColorExposureOperation.cpp
+ operations/COM_ColorExposureOperation.h
operations/COM_ColorMatteOperation.cpp
operations/COM_ColorMatteOperation.h
operations/COM_ColorRampOperation.cpp
diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp
index d8f67571ee5..08035940667 100644
--- a/source/blender/compositor/intern/COM_Converter.cpp
+++ b/source/blender/compositor/intern/COM_Converter.cpp
@@ -37,6 +37,7 @@
#include "COM_ColorBalanceNode.h"
#include "COM_ColorCorrectionNode.h"
#include "COM_ColorCurveNode.h"
+#include "COM_ColorExposureNode.h"
#include "COM_ColorMatteNode.h"
#include "COM_ColorNode.h"
#include "COM_ColorRampNode.h"
@@ -411,6 +412,9 @@ Node *Converter::convert(bNode *b_node)
case CMP_NODE_DENOISE:
node = new DenoiseNode(b_node);
break;
+ case CMP_NODE_EXPOSURE:
+ node = new ExposureNode(b_node);
+ break;
}
return node;
}
diff --git a/source/blender/compositor/nodes/COM_ColorExposureNode.cpp b/source/blender/compositor/nodes/COM_ColorExposureNode.cpp
new file mode 100644
index 00000000000..10738fcfe47
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorExposureNode.cpp
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ *
+ * Copyright 2020, Blender Foundation.
+ */
+
+#include "COM_ColorExposureNode.h"
+#include "COM_ColorExposureOperation.h"
+#include "COM_ExecutionSystem.h"
+
+ExposureNode::ExposureNode(bNode *editorNode) : Node(editorNode)
+{
+ /* pass */
+}
+
+void ExposureNode::convertToOperations(NodeConverter &converter,
+ const CompositorContext & /*context*/) const
+{
+ ExposureOperation *operation = new ExposureOperation();
+ converter.addOperation(operation);
+
+ converter.mapInputSocket(getInputSocket(0), operation->getInputSocket(0));
+ converter.mapInputSocket(getInputSocket(1), operation->getInputSocket(1));
+ converter.mapOutputSocket(getOutputSocket(0), operation->getOutputSocket(0));
+}
diff --git a/source/blender/compositor/nodes/COM_ColorExposureNode.h b/source/blender/compositor/nodes/COM_ColorExposureNode.h
new file mode 100644
index 00000000000..18aefb7eae4
--- /dev/null
+++ b/source/blender/compositor/nodes/COM_ColorExposureNode.h
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ *
+ * Copyright 2020, Blender Foundation.
+ */
+
+#ifndef __COM_EXPOSURENODE_H__
+#define __COM_EXPOSURENODE_H__
+
+#include "COM_Node.h"
+
+/**
+ * \brief ExposureNode
+ * \ingroup Node
+ */
+class ExposureNode : public Node {
+ public:
+ ExposureNode(bNode *editorNode);
+ void convertToOperations(NodeConverter &converter, const CompositorContext &context) const;
+};
+
+#endif
diff --git a/source/blender/compositor/operations/COM_ColorExposureOperation.cpp b/source/blender/compositor/operations/COM_ColorExposureOperation.cpp
new file mode 100644
index 00000000000..8a475432cc8
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorExposureOperation.cpp
@@ -0,0 +1,57 @@
+/*
+ * 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.
+ *
+ * Copyright 2020, Blender Foundation.
+ */
+
+#include "COM_ColorExposureOperation.h"
+
+ExposureOperation::ExposureOperation() : NodeOperation()
+{
+ this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addOutputSocket(COM_DT_COLOR);
+ this->m_inputProgram = NULL;
+}
+
+void ExposureOperation::initExecution()
+{
+ this->m_inputProgram = this->getInputSocketReader(0);
+ this->m_inputExposureProgram = this->getInputSocketReader(1);
+}
+
+void ExposureOperation::executePixelSampled(float output[4],
+ float x,
+ float y,
+ PixelSampler sampler)
+{
+ float inputValue[4];
+ float inputExposure[4];
+ this->m_inputProgram->readSampled(inputValue, x, y, sampler);
+ this->m_inputExposureProgram->readSampled(inputExposure, x, y, sampler);
+ const float exposure = pow(2, inputExposure[0]);
+
+ output[0] = inputValue[0] * exposure;
+ output[1] = inputValue[1] * exposure;
+ output[2] = inputValue[2] * exposure;
+
+ output[3] = inputValue[3];
+}
+
+void ExposureOperation::deinitExecution()
+{
+ this->m_inputProgram = NULL;
+ this->m_inputExposureProgram = NULL;
+}
diff --git a/source/blender/compositor/operations/COM_ColorExposureOperation.h b/source/blender/compositor/operations/COM_ColorExposureOperation.h
new file mode 100644
index 00000000000..a65d5acbe6c
--- /dev/null
+++ b/source/blender/compositor/operations/COM_ColorExposureOperation.h
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ *
+ * Copyright 2020, Blender Foundation.
+ */
+
+#ifndef __COM_COLOREXPOSUREOPERATION_H__
+#define __COM_COLOREXPOSUREOPERATION_H__
+#include "COM_NodeOperation.h"
+
+class ExposureOperation : public NodeOperation {
+ private:
+ /**
+ * Cached reference to the inputProgram
+ */
+ SocketReader *m_inputProgram;
+ SocketReader *m_inputExposureProgram;
+
+ public:
+ ExposureOperation();
+
+ /**
+ * the inner loop of this program
+ */
+ void executePixelSampled(float output[4], float x, float y, PixelSampler sampler);
+
+ /**
+ * Initialize the execution
+ */
+ void initExecution();
+
+ /**
+ * Deinitialize the execution
+ */
+ void deinitExecution();
+};
+#endif
diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h
index aaa948dbff6..2d2e8d1a686 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -149,6 +149,7 @@ extern StructRNA RNA_CompositorNodeDilateErode;
extern StructRNA RNA_CompositorNodeDisplace;
extern StructRNA RNA_CompositorNodeDistanceMatte;
extern StructRNA RNA_CompositorNodeDoubleEdgeMask;
+extern StructRNA RNA_CompositorNodeExposure;
extern StructRNA RNA_CompositorNodeFilter;
extern StructRNA RNA_CompositorNodeFlip;
extern StructRNA RNA_CompositorNodeGamma;
diff --git a/source/blender/nodes/CMakeLists.txt b/source/blender/nodes/CMakeLists.txt
index 866cf74d35b..60d4ee8f7c4 100644
--- a/source/blender/nodes/CMakeLists.txt
+++ b/source/blender/nodes/CMakeLists.txt
@@ -73,6 +73,7 @@ set(SRC
composite/nodes/node_composite_distanceMatte.c
composite/nodes/node_composite_doubleEdgeMask.c
composite/nodes/node_composite_ellipsemask.c
+ composite/nodes/node_composite_exposure.c
composite/nodes/node_composite_filter.c
composite/nodes/node_composite_flip.c
composite/nodes/node_composite_gamma.c
diff --git a/source/blender/nodes/NOD_composite.h b/source/blender/nodes/NOD_composite.h
index 99bcb849ebd..6ad02986010 100644
--- a/source/blender/nodes/NOD_composite.h
+++ b/source/blender/nodes/NOD_composite.h
@@ -56,6 +56,7 @@ void register_node_type_cmp_mix_rgb(void);
void register_node_type_cmp_hue_sat(void);
void register_node_type_cmp_brightcontrast(void);
void register_node_type_cmp_gamma(void);
+void register_node_type_cmp_exposure(void);
void register_node_type_cmp_invert(void);
void register_node_type_cmp_alphaover(void);
void register_node_type_cmp_zcombine(void);
diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h
index 5b61594cca1..5156bac0e73 100644
--- a/source/blender/nodes/NOD_static_types.h
+++ b/source/blender/nodes/NOD_static_types.h
@@ -222,6 +222,7 @@ DefNode(CompositorNode, CMP_NODE_CORNERPIN, 0, "CORNER
DefNode(CompositorNode, CMP_NODE_SUNBEAMS, def_cmp_sunbeams, "SUNBEAMS", SunBeams, "Sun Beams", "" )
DefNode(CompositorNode, CMP_NODE_CRYPTOMATTE, def_cmp_cryptomatte, "CRYPTOMATTE", Cryptomatte, "Cryptomatte", "" )
DefNode(CompositorNode, CMP_NODE_DENOISE, def_cmp_denoise, "DENOISE", Denoise, "Denoise", "" )
+DefNode(CompositorNode, CMP_NODE_EXPOSURE, 0, "EXPOSURE", Exposure, "Exposure", "" )
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/nodes/node_composite_exposure.c b/source/blender/nodes/composite/nodes/node_composite_exposure.c
new file mode 100644
index 00000000000..bd27e4a3d76
--- /dev/null
+++ b/source/blender/nodes/composite/nodes/node_composite_exposure.c
@@ -0,0 +1,46 @@
+/*
+ * 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) 2020 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup cmpnodes
+ */
+
+#include "node_composite_util.h"
+
+/* **************** Exposure ******************** */
+
+static bNodeSocketTemplate cmp_node_exposure_in[] = {
+ {SOCK_RGBA, N_("Image"), 1.0f, 1.0f, 1.0f, 1.0f},
+ {SOCK_FLOAT, N_("Exposure"), 0.0f, 0.0f, 0.0f, 0.0f, -10.0f, 10.0f, PROP_NONE},
+ {-1, ""},
+};
+static bNodeSocketTemplate cmp_node_exposure_out[] = {
+ {SOCK_RGBA, N_("Image")},
+ {-1, ""},
+};
+
+void register_node_type_cmp_exposure(void)
+{
+ static bNodeType ntype;
+
+ cmp_node_type_base(&ntype, CMP_NODE_EXPOSURE, "Exposure", NODE_CLASS_OP_COLOR, 0);
+ node_type_socket_templates(&ntype, cmp_node_exposure_in, cmp_node_exposure_out);
+
+ nodeRegisterType(&ntype);
+}