Compositor: Alpha Mode
{D9211} introduced pre-multiplying the color for the keying node. This pre-multiplication should also be done by other keying nodes and should be the default operation for alpha node. This patch will change the logic of keying nodes (Cryptomatte Node, Channel Matte, Chroma Matte, Color Matte, Difference Matte, Distance Matte, Luminance Matte) and breaks old files. The Set alpha node has a mode parameter. This parameter changes the logic to `Apply Mask` the alpha on the RGBA channels of the input color or only replace the alpha channel (old behavior). The replace mode is automatically set for older files. When adding new files the the multiply mode is set. Reviewed By: Sergey Sharybin Differential Revision: https://developer.blender.org/D9630
This commit is contained in:
parent
357e519575
commit
9dbea1db66
Notes:
blender-bot
2023-02-14 00:44:02 +01:00
Referenced by commit 38df935c09
, Fix T84646: Compositor: In Blender 292 "Set Alpha" node is undefined
Referenced by issue #101601, Regression: Cryptomatte doesn't show all objects available
Referenced by issue #84646, Compositor: In Blender 292 "Set Alpha" node is undefined
Referenced by issue #84386, Compositing / Image Editor Alpha Broken
Referenced by issue #83353, Compositing: viewer node doesn't correctly preview 'set alpha' output
Referenced by issue #82154, Compositor Fix SetAlphaOperation
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 (
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
|
@ -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);
|
||||
|
|
@ -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;
|
|
@ -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
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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", "" )
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue