diff options
Diffstat (limited to 'source')
25 files changed, 147 insertions, 63 deletions
diff --git a/source/blender/blenloader/intern/versioning_290.c b/source/blender/blenloader/intern/versioning_290.c index 63ef436d8e2..de59075559d 100644 --- a/source/blender/blenloader/intern/versioning_290.c +++ b/source/blender/blenloader/intern/versioning_290.c @@ -1490,5 +1490,22 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain) */ { /* Keep this block, even when empty. */ + if (!DNA_struct_find(fd->filesdna, "NodeSetAlpha")) { + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + bNodeTree *nodetree = scene->nodetree; + if (nodetree == NULL) { + continue; + } + + LISTBASE_FOREACH (bNode *, node, &nodetree->nodes) { + if (node->type != CMP_NODE_SETALPHA) { + continue; + } + NodeSetAlpha *storage = MEM_callocN(sizeof(NodeSetAlpha), "NodeSetAlpha"); + storage->mode = CMP_NODE_SETALPHA_MODE_REPLACE_ALPHA; + node->storage = storage; + } + } + } } } diff --git a/source/blender/compositor/CMakeLists.txt b/source/blender/compositor/CMakeLists.txt index 26d29f72efb..19eeb90c822 100644 --- a/source/blender/compositor/CMakeLists.txt +++ b/source/blender/compositor/CMakeLists.txt @@ -355,8 +355,6 @@ set(SRC operations/COM_KeyingDespillOperation.h operations/COM_KeyingOperation.cpp operations/COM_KeyingOperation.h - operations/COM_KeyingSetAlphaOperation.cpp - operations/COM_KeyingSetAlphaOperation.h operations/COM_ColorSpillOperation.cpp operations/COM_ColorSpillOperation.h @@ -461,8 +459,10 @@ set(SRC operations/COM_MapRangeOperation.h operations/COM_MapValueOperation.cpp operations/COM_MapValueOperation.h - operations/COM_SetAlphaOperation.cpp - operations/COM_SetAlphaOperation.h + operations/COM_SetAlphaMultiplyOperation.cpp + operations/COM_SetAlphaMultiplyOperation.h + operations/COM_SetAlphaReplaceOperation.cpp + operations/COM_SetAlphaReplaceOperation.h # Distort operation operations/COM_DisplaceOperation.cpp diff --git a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp index c927865489b..598cd7b7745 100644 --- a/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp +++ b/source/blender/compositor/nodes/COM_ChannelMatteNode.cpp @@ -20,7 +20,7 @@ #include "BKE_node.h" #include "COM_ChannelMatteOperation.h" #include "COM_ConvertOperation.h" -#include "COM_SetAlphaOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" ChannelMatteNode::ChannelMatteNode(bNode *editorNode) : Node(editorNode) { @@ -64,7 +64,7 @@ void ChannelMatteNode::convertToOperations(NodeConverter &converter, operation->setSettings((NodeChroma *)node->storage, node->custom2); converter.addOperation(operation); - SetAlphaOperation *operationAlpha = new SetAlphaOperation(); + SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); converter.addOperation(operationAlpha); if (convert != nullptr) { diff --git a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp index 75d161d7d4d..83e88b35f92 100644 --- a/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp +++ b/source/blender/compositor/nodes/COM_ChromaMatteNode.cpp @@ -20,7 +20,7 @@ #include "BKE_node.h" #include "COM_ChromaMatteOperation.h" #include "COM_ConvertOperation.h" -#include "COM_SetAlphaOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" ChromaMatteNode::ChromaMatteNode(bNode *editorNode) : Node(editorNode) { @@ -48,7 +48,7 @@ void ChromaMatteNode::convertToOperations(NodeConverter &converter, operation->setSettings((NodeChroma *)editorsnode->storage); converter.addOperation(operation); - SetAlphaOperation *operationAlpha = new SetAlphaOperation(); + SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); converter.addOperation(operationAlpha); converter.mapInputSocket(inputSocketImage, operationRGBToYCC_Image->getInputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp index f5cb84975e9..865eee5427f 100644 --- a/source/blender/compositor/nodes/COM_ColorMatteNode.cpp +++ b/source/blender/compositor/nodes/COM_ColorMatteNode.cpp @@ -20,7 +20,7 @@ #include "BKE_node.h" #include "COM_ColorMatteOperation.h" #include "COM_ConvertOperation.h" -#include "COM_SetAlphaOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" ColorMatteNode::ColorMatteNode(bNode *editorNode) : Node(editorNode) { @@ -46,7 +46,7 @@ void ColorMatteNode::convertToOperations(NodeConverter &converter, operation->setSettings((NodeChroma *)editorsnode->storage); converter.addOperation(operation); - SetAlphaOperation *operationAlpha = new SetAlphaOperation(); + SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); converter.addOperation(operationAlpha); converter.mapInputSocket(inputSocketImage, operationRGBToHSV_Image->getInputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp index 7ca4e1f76fc..27ef98af8f3 100644 --- a/source/blender/compositor/nodes/COM_CryptomatteNode.cpp +++ b/source/blender/compositor/nodes/COM_CryptomatteNode.cpp @@ -19,13 +19,13 @@ #include "COM_CryptomatteNode.h" #include "COM_ConvertOperation.h" #include "COM_CryptomatteOperation.h" -#include "COM_SetAlphaOperation.h" #include "BLI_assert.h" #include "BLI_hash_mm3.h" #include "BLI_listbase.h" #include "BLI_string.h" +#include "COM_SetAlphaMultiplyOperation.h" #include <iterator> CryptomatteNode::CryptomatteNode(bNode *editorNode) : Node(editorNode) @@ -61,13 +61,13 @@ void CryptomatteNode::convertToOperations(NodeConverter &converter, separateOperation->setChannel(3); converter.addOperation(separateOperation); - SetAlphaOperation *operationAlpha = new SetAlphaOperation(); + SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); converter.addOperation(operationAlpha); converter.addLink(operation->getOutputSocket(0), separateOperation->getInputSocket(0)); converter.addLink(separateOperation->getOutputSocket(0), operationAlpha->getInputSocket(1)); - SetAlphaOperation *clearAlphaOperation = new SetAlphaOperation(); + SetAlphaMultiplyOperation *clearAlphaOperation = new SetAlphaMultiplyOperation(); converter.addOperation(clearAlphaOperation); converter.addInputValue(clearAlphaOperation->getInputSocket(1), 1.0f); diff --git a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp index b579502e068..3d538e9b4a0 100644 --- a/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp +++ b/source/blender/compositor/nodes/COM_DifferenceMatteNode.cpp @@ -19,7 +19,7 @@ #include "COM_DifferenceMatteNode.h" #include "BKE_node.h" #include "COM_DifferenceMatteOperation.h" -#include "COM_SetAlphaOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" DifferenceMatteNode::DifferenceMatteNode(bNode *editorNode) : Node(editorNode) { @@ -43,7 +43,7 @@ void DifferenceMatteNode::convertToOperations(NodeConverter &converter, converter.mapInputSocket(inputSocket2, operationSet->getInputSocket(1)); converter.mapOutputSocket(outputSocketMatte, operationSet->getOutputSocket(0)); - SetAlphaOperation *operation = new SetAlphaOperation(); + SetAlphaMultiplyOperation *operation = new SetAlphaMultiplyOperation(); converter.addOperation(operation); converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp index 946d55d33fc..37aeb5c8504 100644 --- a/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp +++ b/source/blender/compositor/nodes/COM_DistanceMatteNode.cpp @@ -21,7 +21,7 @@ #include "COM_ConvertOperation.h" #include "COM_DistanceRGBMatteOperation.h" #include "COM_DistanceYCCMatteOperation.h" -#include "COM_SetAlphaOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" DistanceMatteNode::DistanceMatteNode(bNode *editorNode) : Node(editorNode) { @@ -39,7 +39,7 @@ void DistanceMatteNode::convertToOperations(NodeConverter &converter, NodeOutput *outputSocketImage = this->getOutputSocket(0); NodeOutput *outputSocketMatte = this->getOutputSocket(1); - SetAlphaOperation *operationAlpha = new SetAlphaOperation(); + SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); converter.addOperation(operationAlpha); /* work in RGB color space */ diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp index 9f0cdcbd552..4e81a412c29 100644 --- a/source/blender/compositor/nodes/COM_KeyingNode.cpp +++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp @@ -32,7 +32,7 @@ #include "COM_DilateErodeOperation.h" -#include "COM_KeyingSetAlphaOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" #include "COM_GaussianAlphaXBlurOperation.h" #include "COM_GaussianAlphaYBlurOperation.h" @@ -323,7 +323,7 @@ void KeyingNode::convertToOperations(NodeConverter &converter, } /* set alpha channel to output image */ - KeyingSetAlphaOperation *alphaOperation = new KeyingSetAlphaOperation(); + SetAlphaMultiplyOperation *alphaOperation = new SetAlphaMultiplyOperation(); converter.addOperation(alphaOperation); converter.mapInputSocket(inputImage, alphaOperation->getInputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp index e435cefeefe..8bfea1eff49 100644 --- a/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp +++ b/source/blender/compositor/nodes/COM_LuminanceMatteNode.cpp @@ -20,7 +20,7 @@ #include "BKE_node.h" #include "COM_ConvertOperation.h" #include "COM_LuminanceMatteOperation.h" -#include "COM_SetAlphaOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" LuminanceMatteNode::LuminanceMatteNode(bNode *editorNode) : Node(editorNode) { @@ -42,7 +42,7 @@ void LuminanceMatteNode::convertToOperations(NodeConverter &converter, converter.mapInputSocket(inputSocket, operationSet->getInputSocket(0)); converter.mapOutputSocket(outputSocketMatte, operationSet->getOutputSocket(0)); - SetAlphaOperation *operation = new SetAlphaOperation(); + SetAlphaMultiplyOperation *operation = new SetAlphaMultiplyOperation(); converter.addOperation(operation); converter.mapInputSocket(inputSocket, operation->getInputSocket(0)); diff --git a/source/blender/compositor/nodes/COM_SetAlphaNode.cpp b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp index 7b722fe4440..233a5e96ff4 100644 --- a/source/blender/compositor/nodes/COM_SetAlphaNode.cpp +++ b/source/blender/compositor/nodes/COM_SetAlphaNode.cpp @@ -18,12 +18,23 @@ #include "COM_SetAlphaNode.h" #include "COM_ExecutionSystem.h" -#include "COM_SetAlphaOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" +#include "COM_SetAlphaReplaceOperation.h" void SetAlphaNode::convertToOperations(NodeConverter &converter, const CompositorContext & /*context*/) const { - SetAlphaOperation *operation = new SetAlphaOperation(); + const bNode *editorNode = this->getbNode(); + const NodeSetAlpha *storage = static_cast<const NodeSetAlpha *>(editorNode->storage); + NodeOperation *operation = nullptr; + switch (storage->mode) { + case CMP_NODE_SETALPHA_MODE_APPLY: + operation = new SetAlphaMultiplyOperation(); + break; + case CMP_NODE_SETALPHA_MODE_REPLACE_ALPHA: + operation = new SetAlphaReplaceOperation(); + break; + } if (!this->getInputSocket(0)->isLinked() && this->getInputSocket(1)->isLinked()) { operation->setResolutionInputSocketIndex(1); diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp index 956a2cc86ee..a2c6fd47771 100644 --- a/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.cpp @@ -111,10 +111,10 @@ void ChannelMatteOperation::executePixelSampled(float output[4], alpha = (alpha - limit_min) / limit_range; } - /* store matte(alpha) value in [0] to go with - * COM_SetAlphaOperation and the Value output + /* Store matte(alpha) value in [0] to go with + * COM_SetAlphaMultiplyOperation and the Value output. */ - /* don't make something that was more transparent less transparent */ + /* Don't make something that was more transparent less transparent. */ output[0] = min(alpha, inColor[3]); } diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp index 389aeaf6fed..29e18047578 100644 --- a/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.cpp @@ -60,8 +60,8 @@ void ChromaMatteOperation::executePixelSampled(float output[4], this->m_inputKeyProgram->readSampled(inKey, x, y, sampler); this->m_inputImageProgram->readSampled(inImage, x, y, sampler); - /* store matte(alpha) value in [0] to go with - * COM_SetAlphaOperation and the Value output + /* Store matte(alpha) value in [0] to go with + * COM_SetAlphaMultiplyOperation and the Value output. */ /* Algorithm from book "Video Demistified," does not include the spill reduction part */ diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp index b8749bec4b8..17ada8d89b2 100644 --- a/source/blender/compositor/operations/COM_ColorMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_ColorMatteOperation.cpp @@ -58,8 +58,8 @@ void ColorMatteOperation::executePixelSampled(float output[4], this->m_inputImageProgram->readSampled(inColor, x, y, sampler); this->m_inputKeyProgram->readSampled(inKey, x, y, sampler); - /* store matte(alpha) value in [0] to go with - * COM_SetAlphaOperation and the Value output + /* Store matte(alpha) value in [0] to go with + * COM_SetAlphaMultiplyOperation and the Value output. */ if ( diff --git a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp index 7d79dcc657d..ecc2fc2e85f 100644 --- a/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DistanceRGBMatteOperation.cpp @@ -65,8 +65,8 @@ void DistanceRGBMatteOperation::executePixelSampled(float output[4], distance = this->calculateDistance(inKey, inImage); - /* store matte(alpha) value in [0] to go with - * COM_SetAlphaOperation and the Value output + /* Store matte(alpha) value in [0] to go with + * COM_SetAlphaMultiplyOperation and the Value output. */ /*make 100% transparent */ diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp index f7cc6e2d4de..096930d0a83 100644 --- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.cpp @@ -68,8 +68,8 @@ void LuminanceMatteOperation::executePixelSampled(float output[4], alpha = (luminance - low) / (high - low); } - /* store matte(alpha) value in [0] to go with - * COM_SetAlphaOperation and the Value output + /* Store matte(alpha) value in [0] to go with + * COM_SetAlphaMultiplyOperation and the Value output. */ /* don't make something that was more transparent less transparent */ diff --git a/source/blender/compositor/operations/COM_KeyingSetAlphaOperation.cpp b/source/blender/compositor/operations/COM_SetAlphaMultiplyOperation.cpp index 47daef8d190..3853a953c26 100644 --- a/source/blender/compositor/operations/COM_KeyingSetAlphaOperation.cpp +++ b/source/blender/compositor/operations/COM_SetAlphaMultiplyOperation.cpp @@ -13,12 +13,12 @@ * 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. + * Copyright 2011, Blender Foundation. */ -#include "COM_KeyingSetAlphaOperation.h" +#include "COM_SetAlphaMultiplyOperation.h" -KeyingSetAlphaOperation::KeyingSetAlphaOperation() +SetAlphaMultiplyOperation::SetAlphaMultiplyOperation() { this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VALUE); @@ -28,16 +28,16 @@ KeyingSetAlphaOperation::KeyingSetAlphaOperation() this->m_inputAlpha = nullptr; } -void KeyingSetAlphaOperation::initExecution() +void SetAlphaMultiplyOperation::initExecution() { this->m_inputColor = getInputSocketReader(0); this->m_inputAlpha = getInputSocketReader(1); } -void KeyingSetAlphaOperation::executePixelSampled(float output[4], - float x, - float y, - PixelSampler sampler) +void SetAlphaMultiplyOperation::executePixelSampled(float output[4], + float x, + float y, + PixelSampler sampler) { float color_input[4]; float alpha_input[4]; @@ -48,7 +48,7 @@ void KeyingSetAlphaOperation::executePixelSampled(float output[4], mul_v4_v4fl(output, color_input, alpha_input[0]); } -void KeyingSetAlphaOperation::deinitExecution() +void SetAlphaMultiplyOperation::deinitExecution() { this->m_inputColor = nullptr; this->m_inputAlpha = nullptr; diff --git a/source/blender/compositor/operations/COM_KeyingSetAlphaOperation.h b/source/blender/compositor/operations/COM_SetAlphaMultiplyOperation.h index b786240f215..db58b18688a 100644 --- a/source/blender/compositor/operations/COM_KeyingSetAlphaOperation.h +++ b/source/blender/compositor/operations/COM_SetAlphaMultiplyOperation.h @@ -13,7 +13,7 @@ * 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. + * Copyright 2011, Blender Foundation. */ #pragma once @@ -21,16 +21,17 @@ #include "COM_NodeOperation.h" /** - * Operation which is used by keying node to modify image's alpha channels. - * It keeps color properly pre-multiplied. + * This operation will apply a mask to its input image. + * + * `output color.rgba = input color.rgba * input alpha` */ -class KeyingSetAlphaOperation : public NodeOperation { +class SetAlphaMultiplyOperation : public NodeOperation { private: SocketReader *m_inputColor; SocketReader *m_inputAlpha; public: - KeyingSetAlphaOperation(); + SetAlphaMultiplyOperation(); void executePixelSampled(float output[4], float x, float y, PixelSampler sampler); diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp b/source/blender/compositor/operations/COM_SetAlphaReplaceOperation.cpp index bf8fbacbfe1..cd6e82902cc 100644 --- a/source/blender/compositor/operations/COM_SetAlphaOperation.cpp +++ b/source/blender/compositor/operations/COM_SetAlphaReplaceOperation.cpp @@ -16,9 +16,9 @@ * Copyright 2011, Blender Foundation. */ -#include "COM_SetAlphaOperation.h" +#include "COM_SetAlphaReplaceOperation.h" -SetAlphaOperation::SetAlphaOperation() +SetAlphaReplaceOperation::SetAlphaReplaceOperation() { this->addInputSocket(COM_DT_COLOR); this->addInputSocket(COM_DT_VALUE); @@ -28,26 +28,25 @@ SetAlphaOperation::SetAlphaOperation() this->m_inputAlpha = nullptr; } -void SetAlphaOperation::initExecution() +void SetAlphaReplaceOperation::initExecution() { this->m_inputColor = getInputSocketReader(0); this->m_inputAlpha = getInputSocketReader(1); } -void SetAlphaOperation::executePixelSampled(float output[4], - float x, - float y, - PixelSampler sampler) +void SetAlphaReplaceOperation::executePixelSampled(float output[4], + float x, + float y, + PixelSampler sampler) { - float alphaInput[4]; + float alpha_input[4]; this->m_inputColor->readSampled(output, x, y, sampler); - this->m_inputAlpha->readSampled(alphaInput, x, y, sampler); - - output[3] = alphaInput[0]; + this->m_inputAlpha->readSampled(alpha_input, x, y, sampler); + output[3] = alpha_input[0]; } -void SetAlphaOperation::deinitExecution() +void SetAlphaReplaceOperation::deinitExecution() { this->m_inputColor = nullptr; this->m_inputAlpha = nullptr; diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.h b/source/blender/compositor/operations/COM_SetAlphaReplaceOperation.h index a84fb0f2228..b4cab82855b 100644 --- a/source/blender/compositor/operations/COM_SetAlphaOperation.h +++ b/source/blender/compositor/operations/COM_SetAlphaReplaceOperation.h @@ -24,7 +24,7 @@ * this program converts an input color to an output value. * it assumes we are in sRGB color space. */ -class SetAlphaOperation : public NodeOperation { +class SetAlphaReplaceOperation : public NodeOperation { private: SocketReader *m_inputColor; SocketReader *m_inputAlpha; @@ -33,7 +33,7 @@ class SetAlphaOperation : public NodeOperation { /** * Default constructor */ - SetAlphaOperation(); + SetAlphaReplaceOperation(); /** * the inner loop of this program diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 409327b0d1c..6c4aa1fd767 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -2331,6 +2331,11 @@ static void node_composit_buts_colorcorrection_ex(uiLayout *layout, uiItemR(row, ptr, "midtones_end", DEFAULT_FLAGS, NULL, ICON_NONE); } +static void node_composit_buts_set_alpha(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + uiItemR(layout, ptr, "mode", DEFAULT_FLAGS, NULL, ICON_NONE); +} + static void node_composit_buts_switch(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { uiItemR(layout, ptr, "check", DEFAULT_FLAGS, NULL, ICON_NONE); @@ -2928,6 +2933,9 @@ static void node_composit_set_butfunc(bNodeType *ntype) ntype->draw_buttons = node_composit_buts_colorcorrection; ntype->draw_buttons_ex = node_composit_buts_colorcorrection_ex; break; + case CMP_NODE_SETALPHA: + ntype->draw_buttons = node_composit_buts_set_alpha; + break; case CMP_NODE_SWITCH: ntype->draw_buttons = node_composit_buts_switch; break; diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index 3b655790de9..f5d27ef3164 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -835,6 +835,11 @@ typedef struct NodeMask { int size_x, size_y; } NodeMask; +typedef struct NodeSetAlpha { + char mode; + char _pad[7]; +} NodeSetAlpha; + typedef struct NodeTexBase { TexMapping tex_mapping; ColorMapping color_mapping; @@ -1468,6 +1473,13 @@ enum { CMP_NODEFLAG_STABILIZE_INVERSE = 1, }; +/* Set Alpha Node. */ +/* `NodeSetAlpha.mode` */ +typedef enum CMPNodeSetAlphaMode { + CMP_NODE_SETALPHA_MODE_APPLY = 0, + CMP_NODE_SETALPHA_MODE_REPLACE_ALPHA = 1, +} CMPNodeSetAlphaMode; + #define CMP_NODE_PLANETRACKDEFORM_MBLUR_SAMPLES_MAX 64 /* Point Density shader node */ diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 0e9e22532dc..b1ecce23732 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -6035,6 +6035,32 @@ static void def_cmp_vector_blur(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); } +static void def_cmp_set_alpha(StructRNA *srna) +{ + PropertyRNA *prop; + + static const EnumPropertyItem mode_items[] = { + {CMP_NODE_SETALPHA_MODE_APPLY, + "APPLY", + 0, + "Apply Mask", + "Multiply the input image's RGBA channels by the alpha input value"}, + {CMP_NODE_SETALPHA_MODE_REPLACE_ALPHA, + "REPLACE_ALPHA", + 0, + "Replace Alpha", + "Replace the input image's alpha channels by the alpha input value"}, + {0, NULL, 0, NULL, NULL}, + }; + + RNA_def_struct_sdna_from(srna, "NodeSetAlpha", "storage"); + + prop = RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_items(prop, mode_items); + RNA_def_property_ui_text(prop, "Mode", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); +} + static void def_cmp_levels(StructRNA *srna) { PropertyRNA *prop; diff --git a/source/blender/nodes/NOD_static_types.h b/source/blender/nodes/NOD_static_types.h index d6ae98594a5..2cd08069f6f 100644 --- a/source/blender/nodes/NOD_static_types.h +++ b/source/blender/nodes/NOD_static_types.h @@ -151,7 +151,7 @@ DefNode(CompositorNode, CMP_NODE_TIME, def_time, "TIME", DefNode(CompositorNode, CMP_NODE_VECBLUR, def_cmp_vector_blur, "VECBLUR", VecBlur, "Vector Blur", "" ) DefNode(CompositorNode, CMP_NODE_SEPRGBA, 0, "SEPRGBA", SepRGBA, "Separate RGBA", "" ) DefNode(CompositorNode, CMP_NODE_SEPHSVA, 0, "SEPHSVA", SepHSVA, "Separate HSVA", "" ) -DefNode(CompositorNode, CMP_NODE_SETALPHA, 0, "SETALPHA", SetAlpha, "Set Alpha", "" ) +DefNode(CompositorNode, CMP_NODE_SETALPHA, def_cmp_set_alpha, "SETALPHA", SetAlpha, "Set Alpha", "" ) DefNode(CompositorNode, CMP_NODE_HUE_SAT, 0, "HUE_SAT", HueSat, "Hue Saturation Value","" ) DefNode(CompositorNode, CMP_NODE_IMAGE, def_cmp_image, "IMAGE", Image, "Image", "" ) DefNode(CompositorNode, CMP_NODE_R_LAYERS, def_cmp_render_layers, "R_LAYERS", RLayers, "Render Layers", "" ) diff --git a/source/blender/nodes/composite/nodes/node_composite_setalpha.c b/source/blender/nodes/composite/nodes/node_composite_setalpha.c index a1ede7dbb1f..1488ff1a25f 100644 --- a/source/blender/nodes/composite/nodes/node_composite_setalpha.c +++ b/source/blender/nodes/composite/nodes/node_composite_setalpha.c @@ -34,12 +34,22 @@ static bNodeSocketTemplate cmp_node_setalpha_out[] = { {-1, ""}, }; +static void node_composit_init_setalpha(bNodeTree *UNUSED(ntree), bNode *node) +{ + NodeSetAlpha *settings = MEM_callocN(sizeof(NodeSetAlpha), __func__); + node->storage = settings; + settings->mode = CMP_NODE_SETALPHA_MODE_APPLY; +} + void register_node_type_cmp_setalpha(void) { static bNodeType ntype; cmp_node_type_base(&ntype, CMP_NODE_SETALPHA, "Set Alpha", NODE_CLASS_CONVERTOR, 0); node_type_socket_templates(&ntype, cmp_node_setalpha_in, cmp_node_setalpha_out); + node_type_init(&ntype, node_composit_init_setalpha); + node_type_storage( + &ntype, "NodeSetAlpha", node_free_standard_storage, node_copy_standard_storage); nodeRegisterType(&ntype); } |