Fix #36113, Translate's wrapping has 1 pixel gap in X and Y after scale node.

The issue with wrapping is that it requires correct interpolation of the border pixels. Since interpolation is done at the far left end of the node tree in buffer/image/etc read operations, the wrapping
setting can not be used directly in those operations (otherwise in-line translate operations would cause conflicts). To make wrapping work correctly we need to add a buffer in front of the translate
operation, which can then be interpolated correctly based on wrapping. The WrapOperation becomes a variant of ReadBufferOperation, which uses its wrapping setting to determine the correct "extend" mode
for interpolation of the buffer.
This commit is contained in:
Lukas Toenne
2013-09-05 10:45:21 +00:00
parent 4a1ce71fd9
commit 8d2e79aaab
5 changed files with 35 additions and 24 deletions

View File

@@ -23,21 +23,9 @@
#include "COM_WrapOperation.h"
WrapOperation::WrapOperation() : NodeOperation()
WrapOperation::WrapOperation() : ReadBufferOperation()
{
this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0);
this->m_inputOperation = NULL;
}
void WrapOperation::initExecution()
{
this->m_inputOperation = this->getInputSocketReader(0);
}
void WrapOperation::deinitExecution()
{
this->m_inputOperation = NULL;
this->m_wrappingType = CMP_NODE_WRAP_NONE;
}
inline float WrapOperation::getWrappedOriginalXPos(float x)
@@ -59,6 +47,7 @@ void WrapOperation::executePixel(float output[4], float x, float y, PixelSampler
float nx, ny;
nx = x;
ny = y;
MemoryBufferExtend extend_x = COM_MB_CLIP, extend_y = COM_MB_CLIP;
switch (m_wrappingType) {
case CMP_NODE_WRAP_NONE:
//Intentionally empty, originalXPos and originalYPos have been set before
@@ -66,20 +55,23 @@ void WrapOperation::executePixel(float output[4], float x, float y, PixelSampler
case CMP_NODE_WRAP_X:
// wrap only on the x-axis
nx = this->getWrappedOriginalXPos(x);
extend_x = COM_MB_REPEAT;
break;
case CMP_NODE_WRAP_Y:
// wrap only on the y-axis
ny = this->getWrappedOriginalYPos(y);
extend_y = COM_MB_REPEAT;
break;
case CMP_NODE_WRAP_XY:
// wrap on both
nx = this->getWrappedOriginalXPos(x);
ny = this->getWrappedOriginalYPos(y);
extend_x = COM_MB_REPEAT;
extend_y = COM_MB_REPEAT;
break;
}
this->m_inputOperation->read(output, nx, ny, sampler);
executePixelExtend(output, nx, ny, sampler, extend_x, extend_y);
}
bool WrapOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
@@ -110,7 +102,7 @@ bool WrapOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOper
}
}
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
return ReadBufferOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
void WrapOperation::setWrapping(int wrapping_type)