[Bf-blender-cvs] [6538f1e600a] master: Compositor: New Exposure Node

Aaron Carlisle noreply at git.blender.org
Sat Dec 19 20:41:22 CET 2020


Commit: 6538f1e600ad5e0ca04e8e166b848dd321023c4b
Author: Aaron Carlisle
Date:   Sat Dec 19 14:40:31 2020 -0500
Branches: master
https://developer.blender.org/rB6538f1e600ad5e0ca04e8e166b848dd321023c4b

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

===================================================================

M	release/scripts/startup/nodeitems_builtins.py
M	source/blender/blenkernel/BKE_node.h
M	source/blender/blenkernel/intern/node.c
M	source/blender/compositor/CMakeLists.txt
M	source/blender/compositor/intern/COM_Converter.cpp
A	source/blender/compositor/nodes/COM_ColorExposureNode.cpp
A	source/blender/compositor/nodes/COM_ColorExposureNode.h
A	source/blender/compositor/operations/COM_ColorExposureOperation.cpp
A	source/blender/compositor/operations/COM_ColorExposureOperation.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/nodes/CMakeLists.txt
M	source/blender/nodes/NOD_composite.h
M	source/blender/nodes/NOD_static_types.h
A	source/blender/nodes/composite/nodes/node_composite_exposure.c

===================================================================

diff --git a/release/scripts/startup/nodeitems_builtins.py b/release/scripts/startup/nodeitems_builtins.py
index 8552b4017e9..7ceb52a55e5 100644
--- a/release/scripts/startup/nodeitems_builtins.py
+++ b/release/scripts/startup/nodeitems_builtins.py
@@ -330,6 +330,7 @@ compositor_node_categories = [
         NodeItem("CompositorNodeHueCorrect"),
         NodeItem("CompositorNodeBrightContrast"),
         NodeItem("CompositorNodeGamma"),
+        NodeItem("CompositorNodeExposure"),        
         NodeItem("CompositorNodeColorCorrection"),
         NodeItem("CompositorNodeTonemap"),
         NodeItem("CompositorNodeZcombine"),
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 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list