diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-11-08 06:16:04 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-11-12 18:29:54 +0300 |
commit | 63f2f82f92936ce642eaa95def1179304ef0b363 (patch) | |
tree | 2c406f9f6f000d6350a9c6f84bc1ca0a39ed5ae3 /source/blender/compositor/operations | |
parent | 03e8202b7b1963bc856ca31b205364ddc569535a (diff) |
Fix T46641: Bicubic transform on ID channel is not bicubic
Better support of bicubic sampling of ID mask output.
The idea is to generate ID mask into a temporary buffer which is then being
interpolated using current sampling method.
This works fine for upscaling or rotating the ID mask but does not work for
scaling down. This is much-much bigger problem of the compositor design and
can't really be solved currently. Same will happen with other nodes like
blur for example.
Reviewers: campbellbarton
Subscribers: ania
Differential Revision: https://developer.blender.org/D1612
Diffstat (limited to 'source/blender/compositor/operations')
-rw-r--r-- | source/blender/compositor/operations/COM_IDMaskOperation.cpp | 29 | ||||
-rw-r--r-- | source/blender/compositor/operations/COM_IDMaskOperation.h | 25 |
2 files changed, 17 insertions, 37 deletions
diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.cpp b/source/blender/compositor/operations/COM_IDMaskOperation.cpp index 68e681c1326..05462d31ed2 100644 --- a/source/blender/compositor/operations/COM_IDMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_IDMaskOperation.cpp @@ -26,26 +26,23 @@ IDMaskOperation::IDMaskOperation() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_VALUE); - this->m_inputProgram = NULL; -} -void IDMaskOperation::initExecution() -{ - this->m_inputProgram = this->getInputSocketReader(0); + this->setComplex(true); } -void IDMaskOperation::executePixelSampled(float output[4], float x, float y, PixelSampler sampler) +void *IDMaskOperation::initializeTileData(rcti *rect) { - float inputValue[4]; - - this->m_inputProgram->readSampled(inputValue, x, y, sampler); - /* 'round' since sampling may adjust value slightly. - * ID-mask input are originally integers too. */ - const float a = (roundf(inputValue[0]) == this->m_objectIndex) ? 1.0f : 0.0f; - output[0] = a; + void *buffer = getInputOperation(0)->initializeTileData(rect); + return buffer; } -void IDMaskOperation::deinitExecution() +void IDMaskOperation::executePixel(float output[4], + int x, + int y, + void *data) { - this->m_inputProgram = NULL; + MemoryBuffer *input_buffer = (MemoryBuffer *)data; + const int buffer_width = input_buffer->getWidth(); + float *buffer = input_buffer->getBuffer(); + int buffer_index = (y * buffer_width + x); + output[0] = (roundf(buffer[buffer_index]) == this->m_objectIndex) ? 1.0f : 0.0f; } - diff --git a/source/blender/compositor/operations/COM_IDMaskOperation.h b/source/blender/compositor/operations/COM_IDMaskOperation.h index dfddc489ca4..841d4a76124 100644 --- a/source/blender/compositor/operations/COM_IDMaskOperation.h +++ b/source/blender/compositor/operations/COM_IDMaskOperation.h @@ -27,30 +27,13 @@ class IDMaskOperation : public NodeOperation { private: - /** - * Cached reference to the inputProgram - */ - SocketReader *m_inputProgram; - float m_objectIndex; public: IDMaskOperation(); - - /** - * 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(); - + + void *initializeTileData(rcti *rect); + void executePixel(float output[4], int x, int y, void *data); + void setObjectIndex(float objectIndex) { this->m_objectIndex = objectIndex; } }; |