Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/nodes/COM_CryptomatteNode.cpp
| Show All 16 Lines | |||||
| */ | */ | ||||
| #include "COM_CryptomatteNode.h" | #include "COM_CryptomatteNode.h" | ||||
| #include "BLI_assert.h" | #include "BLI_assert.h" | ||||
| #include "BLI_hash_mm3.h" | #include "BLI_hash_mm3.h" | ||||
| #include "BLI_string.h" | #include "BLI_string.h" | ||||
| #include "COM_ConvertOperation.h" | #include "COM_ConvertOperation.h" | ||||
| #include "COM_CryptomatteOperation.h" | #include "COM_CryptomatteOperation.h" | ||||
| #include "COM_SetAlphaOperation.h" | #include "COM_SetAlphaMultiplyOperation.h" | ||||
| #include <iterator> | #include <iterator> | ||||
| CryptomatteNode::CryptomatteNode(bNode *editorNode) : Node(editorNode) | CryptomatteNode::CryptomatteNode(bNode *editorNode) : Node(editorNode) | ||||
| { | { | ||||
| /* pass */ | /* pass */ | ||||
| } | } | ||||
| /* This is taken from the Cryptomatte specification 1.0. */ | /* This is taken from the Cryptomatte specification 1.0. */ | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | void CryptomatteNode::convertToOperations(NodeConverter &converter, | ||||
| for (int i = 0; i < getNumberOfInputSockets() - 1; i++) { | for (int i = 0; i < getNumberOfInputSockets() - 1; i++) { | ||||
| converter.mapInputSocket(this->getInputSocket(i + 1), operation->getInputSocket(i)); | converter.mapInputSocket(this->getInputSocket(i + 1), operation->getInputSocket(i)); | ||||
| } | } | ||||
| SeparateChannelOperation *separateOperation = new SeparateChannelOperation; | SeparateChannelOperation *separateOperation = new SeparateChannelOperation; | ||||
| separateOperation->setChannel(3); | separateOperation->setChannel(3); | ||||
| converter.addOperation(separateOperation); | converter.addOperation(separateOperation); | ||||
| SetAlphaOperation *operationAlpha = new SetAlphaOperation(); | SetAlphaMultiplyOperation *operationAlpha = new SetAlphaMultiplyOperation(); | ||||
| converter.addOperation(operationAlpha); | converter.addOperation(operationAlpha); | ||||
| converter.addLink(operation->getOutputSocket(0), separateOperation->getInputSocket(0)); | converter.addLink(operation->getOutputSocket(0), separateOperation->getInputSocket(0)); | ||||
| converter.addLink(separateOperation->getOutputSocket(0), operationAlpha->getInputSocket(1)); | converter.addLink(separateOperation->getOutputSocket(0), operationAlpha->getInputSocket(1)); | ||||
| SetAlphaOperation *clearAlphaOperation = new SetAlphaOperation(); | SetAlphaMultiplyOperation *clearAlphaOperation = new SetAlphaMultiplyOperation(); | ||||
| converter.addOperation(clearAlphaOperation); | converter.addOperation(clearAlphaOperation); | ||||
| converter.addInputValue(clearAlphaOperation->getInputSocket(1), 1.0f); | converter.addInputValue(clearAlphaOperation->getInputSocket(1), 1.0f); | ||||
| converter.addLink(operation->getOutputSocket(0), clearAlphaOperation->getInputSocket(0)); | converter.addLink(operation->getOutputSocket(0), clearAlphaOperation->getInputSocket(0)); | ||||
| converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); | converter.mapInputSocket(inputSocketImage, operationAlpha->getInputSocket(0)); | ||||
| converter.mapOutputSocket(outputSocketMatte, separateOperation->getOutputSocket(0)); | converter.mapOutputSocket(outputSocketMatte, separateOperation->getOutputSocket(0)); | ||||
| converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket(0)); | converter.mapOutputSocket(outputSocketImage, operationAlpha->getOutputSocket(0)); | ||||
| converter.mapOutputSocket(outputSocketPick, clearAlphaOperation->getOutputSocket(0)); | converter.mapOutputSocket(outputSocketPick, clearAlphaOperation->getOutputSocket(0)); | ||||
| } | } | ||||