diff options
author | Aaron Carlisle <Blendify> | 2020-12-19 22:40:31 +0300 |
---|---|---|
committer | Aaron Carlisle <carlisle.b3d@gmail.com> | 2020-12-19 22:41:14 +0300 |
commit | 6538f1e600ad5e0ca04e8e166b848dd321023c4b (patch) | |
tree | 503788d9153bbcd79335213877d19e58e03767f2 /source/blender/compositor | |
parent | 09be4a0917fbdb391341a6bfcc1e918fb75d0fd2 (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/compositor')
6 files changed, 185 insertions, 0 deletions
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 |