diff options
Diffstat (limited to 'source/blender/compositor/operations')
80 files changed, 619 insertions, 262 deletions
diff --git a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h index e5b1f56f06c..113ec245ee6 100644 --- a/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverKeyOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class AlphaOverKeyOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h index 24a991da17b..3c0b955e360 100644 --- a/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverMixedOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class AlphaOverMixedOperation : public MixBaseOperation { private: diff --git a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h index bba3b714f6b..7b7b9238794 100644 --- a/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h +++ b/source/blender/compositor/operations/COM_AlphaOverPremultiplyOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class AlphaOverPremultiplyOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp index d1ddecc0df6..696c0748d69 100644 --- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp @@ -27,8 +27,9 @@ extern "C" { #include "RE_pipeline.h" } -BlurBaseOperation::BlurBaseOperation(DataType data_type=COM_DT_COLOR) : NodeOperation() +BlurBaseOperation::BlurBaseOperation(DataType data_type) : NodeOperation() { + /* data_type is almost always COM_DT_COLOR except for alpha-blur */ this->addInputSocket(data_type); this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(data_type); diff --git a/source/blender/compositor/operations/COM_ChangeHSVOperation.h b/source/blender/compositor/operations/COM_ChangeHSVOperation.h index 9c343db9c3c..ee35fbe01d4 100644 --- a/source/blender/compositor/operations/COM_ChangeHSVOperation.h +++ b/source/blender/compositor/operations/COM_ChangeHSVOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ChangeHSVOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ChannelMatteOperation.h b/source/blender/compositor/operations/COM_ChannelMatteOperation.h index 859df200020..ee17036a78d 100644 --- a/source/blender/compositor/operations/COM_ChannelMatteOperation.h +++ b/source/blender/compositor/operations/COM_ChannelMatteOperation.h @@ -25,14 +25,14 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ChannelMatteOperation : public NodeOperation { private: SocketReader *m_inputImageProgram; - int m_color_space; /* node->custom1 */ + /* int m_color_space; */ /* node->custom1 */ /* UNUSED */ /* TODO ? */ int m_matte_channel; /* node->custom2 */ int m_limit_method; /* node->algorithm */ int m_limit_channel; /* node->channel */ diff --git a/source/blender/compositor/operations/COM_ChromaMatteOperation.h b/source/blender/compositor/operations/COM_ChromaMatteOperation.h index 472a797fa28..eaca05e66ca 100644 --- a/source/blender/compositor/operations/COM_ChromaMatteOperation.h +++ b/source/blender/compositor/operations/COM_ChromaMatteOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ChromaMatteOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h index 479927d30d1..a9c0dff9ad4 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h +++ b/source/blender/compositor/operations/COM_ColorBalanceASCCDLOperation.h @@ -25,8 +25,8 @@ #include "COM_NodeOperation.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ColorBalanceASCCDLOperation : public NodeOperation { protected: diff --git a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h index ec3652da09e..ffc78fae6f1 100644 --- a/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h +++ b/source/blender/compositor/operations/COM_ColorBalanceLGGOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ColorBalanceLGGOperation : public NodeOperation { protected: diff --git a/source/blender/compositor/operations/COM_ColorMatteOperation.h b/source/blender/compositor/operations/COM_ColorMatteOperation.h index ae904f8f938..d996ce34667 100644 --- a/source/blender/compositor/operations/COM_ColorMatteOperation.h +++ b/source/blender/compositor/operations/COM_ColorMatteOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ColorMatteOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ColorSpillOperation.h b/source/blender/compositor/operations/COM_ColorSpillOperation.h index 6e3156819b2..7aac612cb8c 100644 --- a/source/blender/compositor/operations/COM_ColorSpillOperation.h +++ b/source/blender/compositor/operations/COM_ColorSpillOperation.h @@ -25,8 +25,8 @@ #include "COM_NodeOperation.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ColorSpillOperation : public NodeOperation { protected: diff --git a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h index 0b9a07a57ca..b237448d16e 100644 --- a/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorProfileOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertColorProfileOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h index 2a57c997196..9c62ad8dd39 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorToBWOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertColorToBWOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp b/source/blender/compositor/operations/COM_ConvertColorToValueProg.cpp index c872f3e85bb..c09842b1aa9 100644 --- a/source/blender/compositor/operations/COM_ConvertColourToValueProg.cpp +++ b/source/blender/compositor/operations/COM_ConvertColorToValueProg.cpp @@ -20,28 +20,28 @@ * Monique Dewanchand */ -#include "COM_ConvertColourToValueProg.h" +#include "COM_ConvertColorToValueProg.h" -ConvertColourToValueProg::ConvertColourToValueProg() : NodeOperation() +ConvertColorToValueProg::ConvertColorToValueProg() : NodeOperation() { this->addInputSocket(COM_DT_COLOR); this->addOutputSocket(COM_DT_VALUE); this->m_inputOperation = NULL; } -void ConvertColourToValueProg::initExecution() +void ConvertColorToValueProg::initExecution() { this->m_inputOperation = this->getInputSocketReader(0); } -void ConvertColourToValueProg::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertColorToValueProg::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputColor[4]; this->m_inputOperation->read(&inputColor[0], x, y, sampler, inputBuffers); outputValue[0] = (inputColor[0] + inputColor[1] + inputColor[2]) / 3.0f; } -void ConvertColourToValueProg::deinitExecution() +void ConvertColorToValueProg::deinitExecution() { this->m_inputOperation = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertColourToValueProg.h b/source/blender/compositor/operations/COM_ConvertColorToValueProg.h index ebd4bcbd59b..c1ac7ca69ce 100644 --- a/source/blender/compositor/operations/COM_ConvertColourToValueProg.h +++ b/source/blender/compositor/operations/COM_ConvertColorToValueProg.h @@ -20,16 +20,16 @@ * Monique Dewanchand */ -#ifndef _COM_ConvertColourToValueProg_h -#define _COM_ConvertColourToValueProg_h +#ifndef _COM_ConvertColorToValueProg_h +#define _COM_ConvertColorToValueProg_h #include "COM_NodeOperation.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ -class ConvertColourToValueProg : public NodeOperation { +class ConvertColorToValueProg : public NodeOperation { private: /** * Cached reference to the inputProgram @@ -39,7 +39,7 @@ public: /** * Default constructor */ - ConvertColourToValueProg(); + ConvertColorToValueProg(); /** * the inner loop of this program diff --git a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h index f9170dfc7aa..51fa3a677cd 100644 --- a/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertColorToVectorOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertColorToVectorOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h index 966a74c04ad..415befea168 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.h @@ -26,8 +26,8 @@ #include "DNA_object_types.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertDepthToRadiusOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h index f8b6a4c11fa..3babbfb7c1d 100644 --- a/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertHSVToRGBOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertHSVToRGBOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h index 2b5e1871972..50b39928305 100644 --- a/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h +++ b/source/blender/compositor/operations/COM_ConvertKeyToPremulOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertKeyToPremulOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h index 05c6b26b171..173cbb4fc0a 100644 --- a/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h +++ b/source/blender/compositor/operations/COM_ConvertPremulToKeyOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertPremulToKeyOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h index af8a7f78a61..42bd439c8c2 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToHSVOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertRGBToHSVOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h index 97fbdb29874..744e0657dc6 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToYCCOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertRGBToYCCOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h index 89998897782..b470378704e 100644 --- a/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h +++ b/source/blender/compositor/operations/COM_ConvertRGBToYUVOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertRGBToYUVOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp b/source/blender/compositor/operations/COM_ConvertValueToColorProg.cpp index a29a381938f..100a4931d69 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToColourProg.cpp +++ b/source/blender/compositor/operations/COM_ConvertValueToColorProg.cpp @@ -20,20 +20,20 @@ * Monique Dewanchand */ -#include "COM_ConvertValueToColourProg.h" +#include "COM_ConvertValueToColorProg.h" -ConvertValueToColourProg::ConvertValueToColourProg() : NodeOperation() +ConvertValueToColorProg::ConvertValueToColorProg() : NodeOperation() { this->addInputSocket(COM_DT_VALUE); this->addOutputSocket(COM_DT_COLOR); this->m_inputProgram = NULL; } -void ConvertValueToColourProg::initExecution() +void ConvertValueToColorProg::initExecution() { this->m_inputProgram = this->getInputSocketReader(0); } -void ConvertValueToColourProg::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) +void ConvertValueToColorProg::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) { float inputValue[4]; this->m_inputProgram->read(inputValue, x, y, sampler, inputBuffers); @@ -43,7 +43,7 @@ void ConvertValueToColourProg::executePixel(float *color, float x, float y, Pixe color[3] = 1.0f; } -void ConvertValueToColourProg::deinitExecution() +void ConvertValueToColorProg::deinitExecution() { this->m_inputProgram = NULL; } diff --git a/source/blender/compositor/operations/COM_ConvertValueToColourProg.h b/source/blender/compositor/operations/COM_ConvertValueToColorProg.h index 69ce7e9afea..d59964dd400 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToColourProg.h +++ b/source/blender/compositor/operations/COM_ConvertValueToColorProg.h @@ -20,19 +20,19 @@ * Monique Dewanchand */ -#ifndef _COM_ConvertValueToColourProg_h -#define _COM_ConvertValueToColourProg_h +#ifndef _COM_ConvertValueToColorProg_h +#define _COM_ConvertValueToColorProg_h #include "COM_NodeOperation.h" -class ConvertValueToColourProg : public NodeOperation { +class ConvertValueToColorProg : public NodeOperation { private: /** * Cached reference to the inputProgram */ SocketReader *m_inputProgram; public: - ConvertValueToColourProg(); + ConvertValueToColorProg(); /** * the inner loop of this program diff --git a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h index 781b31f7fce..0e79c1ff3df 100644 --- a/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertValueToVectorOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertValueToVectorOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h index 2f1173ba4e8..8225d03d58e 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h +++ b/source/blender/compositor/operations/COM_ConvertVectorToColorOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertVectorToColorOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h index 8770992c69c..a7981e8dc59 100644 --- a/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h +++ b/source/blender/compositor/operations/COM_ConvertVectorToValueOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertVectorToValueOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h index a595fc19bc7..e23dfd8a985 100644 --- a/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertYCCToRGBOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertYCCToRGBOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h index e89f1500d69..3368e0a24df 100644 --- a/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h +++ b/source/blender/compositor/operations/COM_ConvertYUVToRGBOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ConvertYUVToRGBOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp index 75f909e2198..3c4bdfe8e5b 100644 --- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.cpp @@ -49,7 +49,7 @@ void DifferenceMatteOperation::executePixel(float *outputValue, float x, float y float inColor1[4]; float inColor2[4]; - const float tolerence = this->m_settings->t1; + const float tolerance = this->m_settings->t1; const float falloff = this->m_settings->t2; float difference; float alpha; @@ -65,12 +65,12 @@ void DifferenceMatteOperation::executePixel(float *outputValue, float x, float y difference = difference / 3.0f; /*make 100% transparent*/ - if (difference < tolerence) { + if (difference < tolerance) { outputValue[0] = 0.0f; } /*in the falloff region, make partially transparent */ - else if (difference < falloff + tolerence) { - difference = difference - tolerence; + else if (difference < falloff + tolerance) { + difference = difference - tolerance; alpha = difference / falloff; /*only change if more transparent than before */ if (alpha < inColor1[3]) { diff --git a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h index 48eb2626f02..c35550560e1 100644 --- a/source/blender/compositor/operations/COM_DifferenceMatteOperation.h +++ b/source/blender/compositor/operations/COM_DifferenceMatteOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class DifferenceMatteOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp b/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp index 19cca3d25bb..5bdc616fed7 100644 --- a/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp +++ b/source/blender/compositor/operations/COM_DistanceMatteOperation.cpp @@ -49,7 +49,7 @@ void DistanceMatteOperation::executePixel(float *outputValue, float x, float y, float inKey[4]; float inImage[4]; - const float tolerence = this->m_settings->t1; + const float tolerance = this->m_settings->t1; const float falloff = this->m_settings->t2; float distance; @@ -67,12 +67,12 @@ void DistanceMatteOperation::executePixel(float *outputValue, float x, float y, */ /*make 100% transparent */ - if (distance < tolerence) { + if (distance < tolerance) { outputValue[0] = 0.f; } /*in the falloff region, make partially transparent */ - else if (distance < falloff + tolerence) { - distance = distance - tolerence; + else if (distance < falloff + tolerance) { + distance = distance - tolerance; alpha = distance / falloff; /*only change if more transparent than before */ if (alpha < inImage[3]) { diff --git a/source/blender/compositor/operations/COM_DistanceMatteOperation.h b/source/blender/compositor/operations/COM_DistanceMatteOperation.h index 51e139d179e..267aa1fca7a 100644 --- a/source/blender/compositor/operations/COM_DistanceMatteOperation.h +++ b/source/blender/compositor/operations/COM_DistanceMatteOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class DistanceMatteOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp index c3c115b7c3b..e5a145bab2e 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp @@ -781,10 +781,10 @@ static void do_allEdgeDetection(unsigned int t, unsigned int rw, unsigned int *l if (!limask[a]) { // if the inner mask is empty if (lomask[a]) { // if the outer mask is full /* - Next we test all 4 directions around the current pixel: next/prev/up/down - The test ensures that the outer mask is empty and that the inner mask - is also empty. If both conditions are true for any one of the 4 adjacent pixels - then the current pixel is counted as being a true outer edge pixel. + * Next we test all 4 directions around the current pixel: next/prev/up/down + * The test ensures that the outer mask is empty and that the inner mask + * is also empty. If both conditions are true for any one of the 4 adjacent pixels + * then the current pixel is counted as being a true outer edge pixel. */ if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) || (!lomask[pix_prevCol] && !limask[pix_prevCol]) || @@ -843,10 +843,10 @@ static void do_adjacentEdgeDetection(unsigned int t, unsigned int rw, unsigned i if (!limask[a]) { // if the inner mask is empty if (lomask[a]) { // if the outer mask is full /* - Next we test all 4 directions around the current pixel: next/prev/up/down - The test ensures that the outer mask is empty and that the inner mask - is also empty. If both conditions are true for any one of the 4 adjacent pixels - then the current pixel is counted as being a true outer edge pixel. + * Next we test all 4 directions around the current pixel: next/prev/up/down + * The test ensures that the outer mask is empty and that the inner mask + * is also empty. If both conditions are true for any one of the 4 adjacent pixels + * then the current pixel is counted as being a true outer edge pixel. */ if ((!lomask[pix_nextCol] && !limask[pix_nextCol]) || (!lomask[pix_prevCol] && !limask[pix_prevCol]) || @@ -902,65 +902,65 @@ static void do_createEdgeLocationBuffer(unsigned int t, unsigned int rw, unsigne unsigned int outerAccum = 0; // for looping outer edge pixel indexes, represents current position from offset unsigned int gradientAccum = 0; // for looping gradient pixel indexes, represents current position from offset /* - Here we compute the size of buffer needed to hold (row,col) coordinates - for each pixel previously determined to be either gradient, inner edge, - or outer edge. - - Allocation is done by requesting 4 bytes "sizeof(int)" per pixel, even - though gbuf[] is declared as unsigned short* (2 bytes) because we don't - store the pixel indexes, we only store x,y location of pixel in buffer. - - This does make the assumption that x and y can fit in 16 unsigned bits - so if Blender starts doing renders greater than 65536 in either direction - this will need to allocate gbuf[] as unsigned int *and allocate 8 bytes - per flagged pixel. - - In general, the buffer on-screen: - - Example: 9 by 9 pixel block - - . = pixel non-white in both outer and inner mask - o = pixel white in outer, but not inner mask, adjacent to "." pixel - g = pixel white in outer, but not inner mask, not adjacent to "." pixel - i = pixel white in inner mask, adjacent to "g" or "." pixel - F = pixel white in inner mask, only adjacent to other pixels white in the inner mask - - - ......... <----- pixel #80 - ..oooo... - .oggggo.. - .oggiggo. - .ogiFigo. - .oggiggo. - .oggggo.. - ..oooo... - pixel #00 -----> ......... - - gsz = 18 (18 "g" pixels above) - isz = 4 (4 "i" pixels above) - osz = 18 (18 "o" pixels above) - - - The memory in gbuf[] after filling will look like this: - - gradientFillOffset (0 pixels) innerEdgeOffset (18 pixels) outerEdgeOffset (22 pixels) - / / / - / / / - |X Y X Y X Y X Y > <X Y X Y > <X Y X Y X Y > <X Y X Y | <- (x,y) - +--------------------------------> <----------------> <------------------------> <----------------+ - |0 2 4 6 8 10 12 14 > ... <68 70 72 74 > ... <80 82 84 86 88 90 > ... <152 154 156 158 | <- bytes - +--------------------------------> <----------------> <------------------------> <----------------+ - |g0 g0 g1 g1 g2 g2 g3 g3 > <g17 g17 i0 i0 > <i2 i2 i3 i3 o0 o0 > <o16 o16 o17 o17 | <- pixel - / / / - / / / - / / / - +---------- gradientAccum (18) ---------+ +--- innerAccum (22) ---+ +--- outerAccum (40) ---+ - - - Ultimately we do need the pixel's memory buffer index to set the output - pixel color, but it's faster to reconstruct the memory buffer location - each iteration of the final gradient calculation than it is to deconstruct - a memory location into x,y pairs each round. + * Here we compute the size of buffer needed to hold (row,col) coordinates + * for each pixel previously determined to be either gradient, inner edge, + * or outer edge. + * + * Allocation is done by requesting 4 bytes "sizeof(int)" per pixel, even + * though gbuf[] is declared as unsigned short* (2 bytes) because we don't + * store the pixel indexes, we only store x,y location of pixel in buffer. + * + * This does make the assumption that x and y can fit in 16 unsigned bits + * so if Blender starts doing renders greater than 65536 in either direction + * this will need to allocate gbuf[] as unsigned int *and allocate 8 bytes + * per flagged pixel. + * + * In general, the buffer on-screen: + * + * Example: 9 by 9 pixel block + * + * . = pixel non-white in both outer and inner mask + * o = pixel white in outer, but not inner mask, adjacent to "." pixel + * g = pixel white in outer, but not inner mask, not adjacent to "." pixel + * i = pixel white in inner mask, adjacent to "g" or "." pixel + * F = pixel white in inner mask, only adjacent to other pixels white in the inner mask + * + * + * ......... <----- pixel #80 + * ..oooo... + * .oggggo.. + * .oggiggo. + * .ogiFigo. + * .oggiggo. + * .oggggo.. + * ..oooo... + * pixel #00 -----> ......... + * + * gsz = 18 (18 "g" pixels above) + * isz = 4 (4 "i" pixels above) + * osz = 18 (18 "o" pixels above) + * + * + * The memory in gbuf[] after filling will look like this: + * + * gradientFillOffset (0 pixels) innerEdgeOffset (18 pixels) outerEdgeOffset (22 pixels) + * / / / + * / / / + * |X Y X Y X Y X Y > <X Y X Y > <X Y X Y X Y > <X Y X Y | <- (x,y) + * +--------------------------------> <----------------> <------------------------> <----------------+ + * |0 2 4 6 8 10 12 14 > ... <68 70 72 74 > ... <80 82 84 86 88 90 > ... <152 154 156 158 | <- bytes + * +--------------------------------> <----------------> <------------------------> <----------------+ + * |g0 g0 g1 g1 g2 g2 g3 g3 > <g17 g17 i0 i0 > <i2 i2 i3 i3 o0 o0 > <o16 o16 o17 o17 | <- pixel + * / / / + * / / / + * / / / + * +---------- gradientAccum (18) ---------+ +--- innerAccum (22) ---+ +--- outerAccum (40) ---+ + * + * + * Ultimately we do need the pixel's memory buffer index to set the output + * pixel color, but it's faster to reconstruct the memory buffer location + * each iteration of the final gradient calculation than it is to deconstruct + * a memory location into x,y pairs each round. */ diff --git a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp index 694aa26bcde..cb4c27a4c80 100644 --- a/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareFogGlowOperation.cpp @@ -120,8 +120,8 @@ static void FHT(fREAL *data, unsigned int M, unsigned int inverse) } //------------------------------------------------------------------------------ /* 2D Fast Hartley Transform, Mx/My -> log2 of width/height, - nzp -> the row where zero pad data starts, - inverse -> see above */ + * nzp -> the row where zero pad data starts, + * inverse -> see above */ static void FHT2D(fREAL *data, unsigned int Mx, unsigned int My, unsigned int nzp, unsigned int inverse) { diff --git a/source/blender/compositor/operations/COM_KeyingClipOperation.h b/source/blender/compositor/operations/COM_KeyingClipOperation.h index bffcdb96877..1a8e71a306b 100644 --- a/source/blender/compositor/operations/COM_KeyingClipOperation.h +++ b/source/blender/compositor/operations/COM_KeyingClipOperation.h @@ -27,8 +27,8 @@ #include "COM_NodeOperation.h" /** - * Class with implementation of black/white clipping for keying node - */ + * Class with implementation of black/white clipping for keying node + */ class KeyingClipOperation : public NodeOperation { protected: float m_clipBlack; diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.h b/source/blender/compositor/operations/COM_KeyingDespillOperation.h index 879ee0acaca..4fea9b578a1 100644 --- a/source/blender/compositor/operations/COM_KeyingDespillOperation.h +++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.h @@ -27,8 +27,8 @@ #include "COM_NodeOperation.h" /** - * Class with implementation of keying despill node - */ + * Class with implementation of keying despill node + */ class KeyingDespillOperation : public NodeOperation { protected: SocketReader *m_pixelReader; diff --git a/source/blender/compositor/operations/COM_KeyingOperation.h b/source/blender/compositor/operations/COM_KeyingOperation.h index 61036bead80..736db54850a 100644 --- a/source/blender/compositor/operations/COM_KeyingOperation.h +++ b/source/blender/compositor/operations/COM_KeyingOperation.h @@ -32,8 +32,8 @@ #include "BLI_listbase.h" /** - * Class with implementation of keying node - */ + * Class with implementation of keying node + */ class KeyingOperation : public NodeOperation { protected: SocketReader *m_pixelReader; diff --git a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h index 7da56465cd8..041fd0d7ee9 100644 --- a/source/blender/compositor/operations/COM_LuminanceMatteOperation.h +++ b/source/blender/compositor/operations/COM_LuminanceMatteOperation.h @@ -25,8 +25,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class LuminanceMatteOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_MapValueOperation.h b/source/blender/compositor/operations/COM_MapValueOperation.h index 53157c39938..fb50d0fbe4d 100644 --- a/source/blender/compositor/operations/COM_MapValueOperation.h +++ b/source/blender/compositor/operations/COM_MapValueOperation.h @@ -26,8 +26,8 @@ #include "DNA_texture_types.h" /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MapValueOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_MaskOperation.cpp b/source/blender/compositor/operations/COM_MaskOperation.cpp index aa16ecf5d09..2b45cd53fd5 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.cpp +++ b/source/blender/compositor/operations/COM_MaskOperation.cpp @@ -49,11 +49,19 @@ MaskOperation::MaskOperation() : NodeOperation() void MaskOperation::initExecution() { initMutex(); + this->m_rasterizedMask = NULL; + this->m_maskLayers.first = this->m_maskLayers.last = NULL; + + if (this->m_mask) { + BKE_mask_layer_copy_list(&this->m_maskLayers, &this->m_mask->masklayers); + } } void MaskOperation::deinitExecution() { + BKE_mask_layer_free_list(&this->m_maskLayers); + if (this->m_rasterizedMask) { MEM_freeN(this->m_rasterizedMask); this->m_rasterizedMask = NULL; @@ -75,7 +83,10 @@ void *MaskOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers float *buffer; buffer = (float *)MEM_callocN(sizeof(float) * width * height, "rasterized mask"); - BKE_mask_rasterize(this->m_mask, width, height, buffer, TRUE, this->m_do_smooth, this->m_do_feather); + + BKE_mask_rasterize_layers(&this->m_maskLayers, width, height, buffer, TRUE, + this->m_do_smooth, this->m_do_feather); + if (this->m_do_smooth) { PLX_antialias_buffer(buffer, width, height); } diff --git a/source/blender/compositor/operations/COM_MaskOperation.h b/source/blender/compositor/operations/COM_MaskOperation.h index d50f5c619bb..df1cad3c0f6 100644 --- a/source/blender/compositor/operations/COM_MaskOperation.h +++ b/source/blender/compositor/operations/COM_MaskOperation.h @@ -43,6 +43,7 @@ protected: bool m_do_smooth; bool m_do_feather; float *m_rasterizedMask; + ListBase m_maskLayers; /** * Determine the output resolution. The resolution is retrieved from the Renderer diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.h b/source/blender/compositor/operations/COM_MathBaseOperation.h index bf77223e26f..be06537cbf0 100644 --- a/source/blender/compositor/operations/COM_MathBaseOperation.h +++ b/source/blender/compositor/operations/COM_MathBaseOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MathBaseOperation : public NodeOperation { protected: diff --git a/source/blender/compositor/operations/COM_MixAddOperation.h b/source/blender/compositor/operations/COM_MixAddOperation.h index 7b03802cf7e..c5eaf0a4d77 100644 --- a/source/blender/compositor/operations/COM_MixAddOperation.h +++ b/source/blender/compositor/operations/COM_MixAddOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixAddOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixBaseOperation.h b/source/blender/compositor/operations/COM_MixBaseOperation.h index 8e9bb283533..268d4832243 100644 --- a/source/blender/compositor/operations/COM_MixBaseOperation.h +++ b/source/blender/compositor/operations/COM_MixBaseOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixBaseOperation : public NodeOperation { protected: diff --git a/source/blender/compositor/operations/COM_MixBlendOperation.h b/source/blender/compositor/operations/COM_MixBlendOperation.h index b906134f5cb..16ad635bebd 100644 --- a/source/blender/compositor/operations/COM_MixBlendOperation.h +++ b/source/blender/compositor/operations/COM_MixBlendOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixBlendOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixBurnOperation.h b/source/blender/compositor/operations/COM_MixBurnOperation.h index af09772edde..7412f651ab3 100644 --- a/source/blender/compositor/operations/COM_MixBurnOperation.h +++ b/source/blender/compositor/operations/COM_MixBurnOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixBurnOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixColorOperation.h b/source/blender/compositor/operations/COM_MixColorOperation.h index 9b0d93f934d..028ff517132 100644 --- a/source/blender/compositor/operations/COM_MixColorOperation.h +++ b/source/blender/compositor/operations/COM_MixColorOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixColorOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixDarkenOperation.h b/source/blender/compositor/operations/COM_MixDarkenOperation.h index 69fb4450458..337fa1a7024 100644 --- a/source/blender/compositor/operations/COM_MixDarkenOperation.h +++ b/source/blender/compositor/operations/COM_MixDarkenOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixDarkenOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixDifferenceOperation.h b/source/blender/compositor/operations/COM_MixDifferenceOperation.h index c71b22214cc..503fbb691d3 100644 --- a/source/blender/compositor/operations/COM_MixDifferenceOperation.h +++ b/source/blender/compositor/operations/COM_MixDifferenceOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixDifferenceOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixDivideOperation.h b/source/blender/compositor/operations/COM_MixDivideOperation.h index 375e7129e8b..db60a39f93f 100644 --- a/source/blender/compositor/operations/COM_MixDivideOperation.h +++ b/source/blender/compositor/operations/COM_MixDivideOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixDivideOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixDodgeOperation.h b/source/blender/compositor/operations/COM_MixDodgeOperation.h index a4adf6fde47..32aa8593657 100644 --- a/source/blender/compositor/operations/COM_MixDodgeOperation.h +++ b/source/blender/compositor/operations/COM_MixDodgeOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixDodgeOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixGlareOperation.h b/source/blender/compositor/operations/COM_MixGlareOperation.h index 1a025eb3edd..1c715d7414b 100644 --- a/source/blender/compositor/operations/COM_MixGlareOperation.h +++ b/source/blender/compositor/operations/COM_MixGlareOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixGlareOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixHueOperation.h b/source/blender/compositor/operations/COM_MixHueOperation.h index 56310e253c0..ff1ef369440 100644 --- a/source/blender/compositor/operations/COM_MixHueOperation.h +++ b/source/blender/compositor/operations/COM_MixHueOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixHueOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixLightenOperation.h b/source/blender/compositor/operations/COM_MixLightenOperation.h index bb251a44653..dd51215b26a 100644 --- a/source/blender/compositor/operations/COM_MixLightenOperation.h +++ b/source/blender/compositor/operations/COM_MixLightenOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixLightenOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixLinearLightOperation.h b/source/blender/compositor/operations/COM_MixLinearLightOperation.h index 39d5b6495d1..e96e2b7eaf7 100644 --- a/source/blender/compositor/operations/COM_MixLinearLightOperation.h +++ b/source/blender/compositor/operations/COM_MixLinearLightOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixLinearLightOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixMultiplyOperation.h b/source/blender/compositor/operations/COM_MixMultiplyOperation.h index 2c12854bfa6..4c89a8f2957 100644 --- a/source/blender/compositor/operations/COM_MixMultiplyOperation.h +++ b/source/blender/compositor/operations/COM_MixMultiplyOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixMultiplyOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixOverlayOperation.h b/source/blender/compositor/operations/COM_MixOverlayOperation.h index 48d1d10a697..7de955b9f4f 100644 --- a/source/blender/compositor/operations/COM_MixOverlayOperation.h +++ b/source/blender/compositor/operations/COM_MixOverlayOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixOverlayOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixSaturationOperation.h b/source/blender/compositor/operations/COM_MixSaturationOperation.h index ccb95e2f00f..241009e2645 100644 --- a/source/blender/compositor/operations/COM_MixSaturationOperation.h +++ b/source/blender/compositor/operations/COM_MixSaturationOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixSaturationOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixScreenOperation.h b/source/blender/compositor/operations/COM_MixScreenOperation.h index 6b9fa302325..4d0c1fded3d 100644 --- a/source/blender/compositor/operations/COM_MixScreenOperation.h +++ b/source/blender/compositor/operations/COM_MixScreenOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixScreenOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixSoftLightOperation.h b/source/blender/compositor/operations/COM_MixSoftLightOperation.h index 4189066de2c..bcb718027b2 100644 --- a/source/blender/compositor/operations/COM_MixSoftLightOperation.h +++ b/source/blender/compositor/operations/COM_MixSoftLightOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixSoftLightOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixSubtractOperation.h b/source/blender/compositor/operations/COM_MixSubtractOperation.h index b820fb1e5e1..3c8112b0e36 100644 --- a/source/blender/compositor/operations/COM_MixSubtractOperation.h +++ b/source/blender/compositor/operations/COM_MixSubtractOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixSubtractOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MixValueOperation.h b/source/blender/compositor/operations/COM_MixValueOperation.h index d12a2d2b3d6..c0f3ce10f29 100644 --- a/source/blender/compositor/operations/COM_MixValueOperation.h +++ b/source/blender/compositor/operations/COM_MixValueOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MixValueOperation : public MixBaseOperation { public: diff --git a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h index ba104d07572..c6422fbbfc2 100644 --- a/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h +++ b/source/blender/compositor/operations/COM_MovieClipAttributeOperation.h @@ -32,8 +32,8 @@ typedef enum MovieClipAttribute { MCA_ANGLE } MovieClipAttribute; /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class MovieClipAttributeOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp index 50bac63d6f2..74145c52a5d 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp @@ -36,6 +36,7 @@ ProjectorLensDistortionOperation::ProjectorLensDistortionOperation() : NodeOpera } void ProjectorLensDistortionOperation::initExecution() { + this->initMutex(); this->m_inputProgram = this->getInputSocketReader(0); } @@ -65,6 +66,7 @@ void ProjectorLensDistortionOperation::executePixel(float *color, int x, int y, void ProjectorLensDistortionOperation::deinitExecution() { + this->deinitMutex(); this->m_inputProgram = NULL; } @@ -77,16 +79,18 @@ bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(rcti *in newInput.xmin = input->xmin - this->m_kr2 - 2; newInput.xmax = input->xmax + this->m_kr2 + 2; } else { - newInput.xmin = 0; + newInput.xmin = input->xmin-7; //(0.25f*20*1)+2 == worse case dispersion newInput.ymin = input->ymin; newInput.ymax = input->ymax; - newInput.xmax = this->m_inputProgram->getWidth(); + newInput.xmax = input->xmax+7; //(0.25f*20*1)+2 == worse case dispersion } return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } void ProjectorLensDistortionOperation::updateDispersion(MemoryBuffer **inputBuffers) { + if (this->m_dispersionAvailable) return; + this->lockMutex(); if (!this->m_dispersionAvailable) { float result[4]; this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); @@ -95,4 +99,5 @@ void ProjectorLensDistortionOperation::updateDispersion(MemoryBuffer **inputBuff this->m_kr2 = this->m_kr * 20; this->m_dispersionAvailable = true; } + this->unlockMutex(); } diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h index f992b22f300..c658d66429a 100644 --- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h +++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h @@ -61,7 +61,7 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); - void updateDispersion(MemoryBuffer** inputBuffers); + void updateDispersion(MemoryBuffer **inputBuffers); }; #endif diff --git a/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp b/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp index 14c3d652c42..f21585844ff 100644 --- a/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp +++ b/source/blender/compositor/operations/COM_RenderLayersImageProg.cpp @@ -22,7 +22,7 @@ #include "COM_RenderLayersImageProg.h" -RenderLayersColourProg::RenderLayersColourProg() : RenderLayersBaseProg(SCE_PASS_COMBINED, 4) +RenderLayersColorProg::RenderLayersColorProg() : RenderLayersBaseProg(SCE_PASS_COMBINED, 4) { this->addOutputSocket(COM_DT_COLOR); } diff --git a/source/blender/compositor/operations/COM_RenderLayersImageProg.h b/source/blender/compositor/operations/COM_RenderLayersImageProg.h index b6ddac425cb..2d63bad235b 100644 --- a/source/blender/compositor/operations/COM_RenderLayersImageProg.h +++ b/source/blender/compositor/operations/COM_RenderLayersImageProg.h @@ -20,15 +20,15 @@ * Monique Dewanchand */ -#ifndef _COM_RenderLayersColourProg_h -#define _COM_RenderLayersColourProg_h +#ifndef _COM_RenderLayersColorProg_h +#define _COM_RenderLayersColorProg_h #include "COM_RenderLayersBaseProg.h" /// @TODO rename to image operation -class RenderLayersColourProg : public RenderLayersBaseProg { +class RenderLayersColorProg : public RenderLayersBaseProg { public: - RenderLayersColourProg(); + RenderLayersColorProg(); }; #endif diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp index e3abf2aa70b..ea8483734d3 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp @@ -42,6 +42,10 @@ ScreenLensDistortionOperation::ScreenLensDistortionOperation() : NodeOperation() void ScreenLensDistortionOperation::initExecution() { this->m_inputProgram = this->getInputSocketReader(0); + this->initMutex(); + this->m_cx = 0.5f * (float)getWidth(); + this->m_cy = 0.5f * (float)getHeight(); + } void *ScreenLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) @@ -139,52 +143,192 @@ void ScreenLensDistortionOperation::executePixel(float *outputColor, int x, int void ScreenLensDistortionOperation::deinitExecution() { + this->deinitMutex(); this->m_inputProgram = NULL; } -void ScreenLensDistortionOperation::determineUV(float result[2], float x, float y) const +void ScreenLensDistortionOperation::determineUV(float result[4], float x, float y, float distortion, float dispersion) +{ + if (!this->m_valuesAvailable) { + updateVariables(distortion, dispersion); + } + determineUV(result, x, y); +} + +void ScreenLensDistortionOperation::determineUV(float result[4], float x, float y) const { + const float height = this->getHeight(); + const float width = this->getWidth(); + + float d, t, ln[6] = {0, 0, 0, 0, 0, 0}; const float v = this->m_sc * ((y + 0.5f) - this->m_cy) / this->m_cy; const float u = this->m_sc * ((x + 0.5f) - this->m_cx) / this->m_cx; - const float t = ABS(MIN3(this->m_kr, this->m_kg, this->m_kb) * 4); - float d = 1.f / (1.f + sqrtf(t)); - result[0] = (u * d + 0.5f) * getWidth() - 0.5f; - result[1] = (v * d + 0.5f) * getHeight() - 0.5f; + const float uv_dot = u * u + v * v; + + if ((t = 1.f - this->m_kr4 * uv_dot) >= 0.f) { + d = 1.f / (1.f + sqrtf(t)); + ln[0] = (u * d + 0.5f) * width - 0.5f, ln[1] = (v * d + 0.5f) * height - 0.5f; + } + if ((t = 1.f - this->m_kg4 * uv_dot) >= 0.f) { + d = 1.f / (1.f + sqrtf(t)); + ln[2] = (u * d + 0.5f) * width - 0.5f, ln[3] = (v * d + 0.5f) * height - 0.5f; + } + if ((t = 1.f - this->m_kb4 * uv_dot) >= 0.f) { + d = 1.f / (1.f + sqrtf(t)); + ln[4] = (u * d + 0.5f) * width - 0.5f, ln[5] = (v * d + 0.5f) * height - 0.5f; + } + + float jit = this->m_data->jit; + float z; + { + // RG + const int dx = ln[2] - ln[0], dy = ln[3] - ln[1]; + const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.f; + const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf); + const float sd = 1.f / (float)ds; + + z = ds; + const float tz = ((float)z + (1.0f)) * sd; + t = 1.0f - (this->m_kr4 + tz * this->m_drg) * uv_dot; + d = 1.0f / (1.f + sqrtf(t)); + const float nx = (u * d + 0.5f) * width - 0.5f; + const float ny = (v * d + 0.5f) * height - 0.5f; + result[0] = nx; + result[1] = ny; + } + { + // GB + const int dx = ln[4] - ln[2], dy = ln[5] - ln[3]; + const float dsf = sqrtf((float)dx * dx + dy * dy) + 1.f; + const int ds = (int)(jit ? ((dsf < 4.f) ? 2.f : sqrtf(dsf)) : dsf); + const float sd = 1.f / (float)ds; + + z = ds; + const float tz = ((float)z + (1.0f)) * sd; + t = 1.f - (this->m_kg4 + tz * this->m_dgb) * uv_dot; + d = 1.f / (1.f + sqrtf(t)); + const float nx = (u * d + 0.5f) * width - 0.5f; + const float ny = (v * d + 0.5f) * height - 0.5f; + result[2] = nx; + result[3] = ny; + } } bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) { + rcti newInputValue; + newInputValue.xmin = 0; + newInputValue.ymin = 0; + newInputValue.xmax = 2; + newInputValue.ymax = 2; + + NodeOperation *operation = getInputOperation(1); + if (operation->determineDependingAreaOfInterest(&newInputValue, readOperation, output) ) { + return true; + } + + operation = getInputOperation(2); + if (operation->determineDependingAreaOfInterest(&newInputValue, readOperation, output) ) { + return true; + } + +#define MARGIN 64 + +#define UPDATE_INPUT \ + newInput.xmin = MIN3(newInput.xmin, coords[0], coords[2]); \ + newInput.ymin = MIN3(newInput.ymin, coords[1], coords[3]); \ + newInput.xmax = MAX3(newInput.xmax, coords[0], coords[2]); \ + newInput.ymax = MAX3(newInput.ymax, coords[1], coords[3]); + rcti newInput; - newInput.xmin = 0; - newInput.ymin = 0; - newInput.ymax = this->m_inputProgram->getHeight(); - newInput.xmax = this->m_inputProgram->getWidth(); - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + float margin; + float coords[4]; + if (m_valuesAvailable) { + determineUV(coords, input->xmin, input->ymin); + newInput.xmin = coords[0]; + newInput.ymin = coords[1]; + newInput.xmax = coords[0]; + newInput.ymax = coords[1]; + UPDATE_INPUT; + determineUV(coords, input->xmin, input->ymax); + UPDATE_INPUT; + determineUV(coords, input->xmax, input->ymax); + UPDATE_INPUT; + determineUV(coords, input->xmax, input->ymin); + UPDATE_INPUT; + margin = (ABS(this->m_distortion)+this->m_dispersion)*MARGIN; + } + else + { + determineUV(coords, input->xmin, input->ymin, 1.0f, 1.0f); + newInput.xmin = coords[0]; + newInput.ymin = coords[1]; + newInput.xmax = coords[0]; + newInput.ymax = coords[1]; + UPDATE_INPUT; + determineUV(coords, input->xmin, input->ymin, -1.0f, 1.0f); + UPDATE_INPUT; + + determineUV(coords, input->xmin, input->ymax, -1.0f, 1.0f); + UPDATE_INPUT; + determineUV(coords, input->xmin, input->ymax, 1.0f, 1.0f); + UPDATE_INPUT; + + determineUV(coords, input->xmax, input->ymax, -1.0f, 1.0f); + UPDATE_INPUT; + determineUV(coords, input->xmax, input->ymax, 1.0f, 1.0f); + UPDATE_INPUT; + + determineUV(coords, input->xmax, input->ymin, -1.0f, 1.0f); + UPDATE_INPUT; + determineUV(coords, input->xmax, input->ymin, 1.0f, 1.0f); + UPDATE_INPUT; + margin=MARGIN; + } + +#undef UPDATE_INPUT + newInput.xmin -= margin; + newInput.ymin -= margin; + newInput.xmax += margin; + newInput.ymax += margin; + + operation = getInputOperation(0); + if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { + return true; + } + return false; +} + +void ScreenLensDistortionOperation::updateVariables(float distortion, float dispersion) +{ + this->m_kg = MAX2(MIN2(distortion, 1.f), -0.999f); + // smaller dispersion range for somewhat more control + const float d = 0.25f * MAX2(MIN2(dispersion, 1.f), 0.f); + this->m_kr = MAX2(MIN2((this->m_kg + d), 1.0f), -0.999f); + this->m_kb = MAX2(MIN2((this->m_kg - d), 1.0f), -0.999f); + this->m_maxk = MAX3(this->m_kr, this->m_kg, this->m_kb); + this->m_sc = (this->m_data->fit && (this->m_maxk > 0.f)) ? (1.f / (1.f + 2.f * this->m_maxk)) : (1.f / (1.f + this->m_maxk)); + this->m_drg = 4.f * (this->m_kg - this->m_kr); + this->m_dgb = 4.f * (this->m_kb - this->m_kg); + + this->m_kr4 = this->m_kr * 4.0f; + this->m_kg4 = this->m_kg * 4.0f; + this->m_kb4 = this->m_kb * 4.0f; } void ScreenLensDistortionOperation::updateDispersionAndDistortion(MemoryBuffer **inputBuffers) { + if (this->m_valuesAvailable) return; + + this->lockMutex(); if (!this->m_valuesAvailable) { float result[4]; this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); this->m_distortion = result[0]; this->getInputSocketReader(2)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers); this->m_dispersion = result[0]; - this->m_kg = MAX2(MIN2(this->m_distortion, 1.f), -0.999f); - // smaller dispersion range for somewhat more control - const float d = 0.25f * MAX2(MIN2(this->m_dispersion, 1.f), 0.f); - this->m_kr = MAX2(MIN2((this->m_kg + d), 1.0f), -0.999f); - this->m_kb = MAX2(MIN2((this->m_kg - d), 1.0f), -0.999f); - this->m_maxk = MAX3(this->m_kr, this->m_kg, this->m_kb); - this->m_sc = (this->m_data->fit && (this->m_maxk > 0.f)) ? (1.f / (1.f + 2.f * this->m_maxk)) : (1.f / (1.f + this->m_maxk)); - this->m_drg = 4.f * (this->m_kg - this->m_kr); - this->m_dgb = 4.f * (this->m_kb - this->m_kg); - - this->m_kr4 = this->m_kr * 4.0f; - this->m_kg4 = this->m_kg * 4.0f; - this->m_kb4 = this->m_kb * 4.0f; - this->m_cx = 0.5f * (float)getWidth(); - this->m_cy = 0.5f * (float)getHeight(); + updateVariables(this->m_distortion, this->m_dispersion); this->m_valuesAvailable = true; } + this->unlockMutex(); } diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h index d990651dd7d..f80b938818c 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h @@ -66,9 +66,23 @@ public: bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + /** + * @brief Set the distortion and dispersion and precalc some values + * @param distortion + * @param dispersion + */ + void setDistortionAndDispersion(float distortion, float dispersion) { + this->m_distortion = distortion; + this->m_dispersion = dispersion; + updateVariables(distortion, dispersion); + this->m_valuesAvailable = true; + } + private: - void determineUV(float *result, float x, float y) const; - void updateDispersionAndDistortion(MemoryBuffer** inputBuffers); + void determineUV(float result[4], float x, float y) const; + void determineUV(float result[4], float x, float y, float distortion, float dispersion); + void updateDispersionAndDistortion(MemoryBuffer **inputBuffers); + void updateVariables(float distortion, float dispersion); }; #endif diff --git a/source/blender/compositor/operations/COM_SetAlphaOperation.h b/source/blender/compositor/operations/COM_SetAlphaOperation.h index 857bd08bfbf..21968c930e7 100644 --- a/source/blender/compositor/operations/COM_SetAlphaOperation.h +++ b/source/blender/compositor/operations/COM_SetAlphaOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class SetAlphaOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_SetColorOperation.h b/source/blender/compositor/operations/COM_SetColorOperation.h index abfa2b9538a..a51311837ee 100644 --- a/source/blender/compositor/operations/COM_SetColorOperation.h +++ b/source/blender/compositor/operations/COM_SetColorOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class SetColorOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_SetSamplerOperation.h b/source/blender/compositor/operations/COM_SetSamplerOperation.h index 24e0c5e2ef5..273eac159bc 100644 --- a/source/blender/compositor/operations/COM_SetSamplerOperation.h +++ b/source/blender/compositor/operations/COM_SetSamplerOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output Sampler. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output Sampler. + * it assumes we are in sRGB color space. */ class SetSamplerOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_SetValueOperation.h b/source/blender/compositor/operations/COM_SetValueOperation.h index dce0c3299ac..642940e03cd 100644 --- a/source/blender/compositor/operations/COM_SetValueOperation.h +++ b/source/blender/compositor/operations/COM_SetValueOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class SetValueOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_SetVectorOperation.h b/source/blender/compositor/operations/COM_SetVectorOperation.h index dc2a05ceff4..d1b9fe25085 100644 --- a/source/blender/compositor/operations/COM_SetVectorOperation.h +++ b/source/blender/compositor/operations/COM_SetVectorOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class SetVectorOperation : public NodeOperation { private: diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp index 9eb004b3686..46101f6355d 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.cpp @@ -33,6 +33,9 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // do not resize the bokeh image. this->addInputSocket(COM_DT_VALUE); // radius this->addInputSocket(COM_DT_VALUE); // depth +#ifdef COM_DEFOCUS_SEARCH + this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE); // inverse search radius optimization structure. +#endif this->addOutputSocket(COM_DT_COLOR); this->setComplex(true); @@ -42,6 +45,9 @@ VariableSizeBokehBlurOperation::VariableSizeBokehBlurOperation() : NodeOperation this->m_inputDepthProgram = NULL; this->m_maxBlur = 32.0f; this->m_threshold = 1.0f; +#ifdef COM_DEFOCUS_SEARCH + this->m_inputSearchProgram = NULL; +#endif } @@ -51,6 +57,9 @@ void VariableSizeBokehBlurOperation::initExecution() this->m_inputBokehProgram = getInputSocketReader(1); this->m_inputSizeProgram = getInputSocketReader(2); this->m_inputDepthProgram = getInputSocketReader(3); +#ifdef COM_DEFOCUS_SEARCH + this->m_inputSearchProgram = getInputSocketReader(4); +#endif QualityStepHelper::initExecution(COM_QH_INCREASE); } @@ -63,10 +72,19 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; - int miny = y - this->m_maxBlur; - int maxy = y + this->m_maxBlur; - int minx = x - this->m_maxBlur; - int maxx = x + this->m_maxBlur; +#ifdef COM_DEFOCUS_SEARCH + float search[4]; + this->inputSearchProgram->read(search, x/InverseSearchRadiusOperation::DIVIDER, y/InverseSearchRadiusOperation::DIVIDER, inputBuffers, NULL); + int minx = search[0]; + int miny = search[1]; + int maxx = search[2]; + int maxy = search[3]; +#else + int minx = MAX2(x - this->m_maxBlur, 0.0f); + int miny = MAX2(y - this->m_maxBlur, 0.0f); + int maxx = MIN2(x + this->m_maxBlur, m_width); + int maxy = MIN2(y + this->m_maxBlur, m_height); +#endif { this->m_inputSizeProgram->read(tempSize, x, y, COM_PS_NEAREST, inputBuffers); this->m_inputDepthProgram->read(tempDepth, x, y, COM_PS_NEAREST, inputBuffers); @@ -80,9 +98,9 @@ void VariableSizeBokehBlurOperation::executePixel(float *color, int x, int y, Me for (int nx = minx; nx < maxx; nx += QualityStepHelper::getStep()) { if (nx >= 0 && nx < this->getWidth() && ny >= 0 && ny < getHeight()) { this->m_inputDepthProgram->read(tempDepth, nx, ny, COM_PS_NEAREST, inputBuffers); - this->m_inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); - float size = tempSize[0]; if (tempDepth[0] < centerDepth) { + this->m_inputSizeProgram->read(tempSize, nx, ny, COM_PS_NEAREST, inputBuffers); + float size = tempSize[0]; if ((sizeCenter > this->m_threshold && size > this->m_threshold) || size <= this->m_threshold) { float dx = nx - x; float dy = ny - y; @@ -115,6 +133,10 @@ void VariableSizeBokehBlurOperation::deinitExecution() this->m_inputProgram = NULL; this->m_inputBokehProgram = NULL; this->m_inputSizeProgram = NULL; + this->m_inputDepthProgram = NULL; +#ifdef COM_DEFOCUS_SEARCH + this->m_inputSearchProgram = NULL; +#endif } bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) @@ -130,6 +152,7 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu bokehInput.xmin = 0; bokehInput.ymax = 512; bokehInput.ymin = 0; + NodeOperation *operation = getInputOperation(2); if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { @@ -143,9 +166,118 @@ bool VariableSizeBokehBlurOperation::determineDependingAreaOfInterest(rcti *inpu if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { return true; } +#ifdef COM_DEFOCUS_SEARCH + rcti searchInput; + searchInput.xmax = (input->xmax/InverseSearchRadiusOperation::DIVIDER)+1; + searchInput.xmin = (input->xmin/InverseSearchRadiusOperation::DIVIDER)-1; + searchInput.ymax = (input->ymax/InverseSearchRadiusOperation::DIVIDER)+1; + searchInput.ymin = (input->ymin/InverseSearchRadiusOperation::DIVIDER)-1; + operation = getInputOperation(4); + if (operation->determineDependingAreaOfInterest(&searchInput, readOperation, output) ) { + return true; + } +#endif operation = getInputOperation(0); if (operation->determineDependingAreaOfInterest(&newInput, readOperation, output) ) { return true; } return false; } + +#ifdef COM_DEFOCUS_SEARCH +// InverseSearchRadiusOperation +InverseSearchRadiusOperation::InverseSearchRadiusOperation() : NodeOperation() +{ + this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // radius + this->addInputSocket(COM_DT_VALUE, COM_SC_NO_RESIZE); // depth + this->addOutputSocket(COM_DT_COLOR); + this->setComplex(true); + this->inputRadius = NULL; + this->inputDepth = NULL; +} + +void InverseSearchRadiusOperation::initExecution() +{ + this->inputRadius = this->getInputSocketReader(0); + this->inputDepth = this->getInputSocketReader(1); +} + +void* InverseSearchRadiusOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers) +{ + MemoryBuffer * data = new MemoryBuffer(NULL, rect); + int x, y; + float width = this->inputRadius->getWidth(); + float height = this->inputRadius->getHeight(); + + for (x = rect->xmin; x < rect->xmax ; x++) { + for (y = rect->ymin; y < rect->ymax ; y++) { + float[4] temp; + int rx = x * DIVIDER; + int ry = y * DIVIDER; + this->inputRadius->read(temp, rx, ry, memoryBuffers, NULL); + float centerRadius = temp[0]; + this->inputDepth->read(temp, rx, ry, memoryBuffers, NULL); + float centerDepth = temp[0]; + t[0] = MAX2(rx - this->maxBlur, 0.0f); + t[1] = MAX2(ry - this->maxBlur, 0.0f); + t[2] = MIN2(rx + this->maxBlur, width); + t[3] = MIN2(ry + this->maxBlur, height); + int minx = t[0]; + int miny = t[1]; + int maxx = t[2]; + int maxy = t[3]; + int sminx = rx; + int smaxx = rx; + int sminy = ry; + int smaxy = ry; + for (int nx = minx ; nx < maxx ; nx ++) { + for (int ny = miny ; ny < maxy ; ny ++) { + this->inputRadius->read(temp, nx, ny, memoryBuffers, NULL); + if (nx < rx && temp[0]) + + } + } + float t[4]; + data->writePixel(x, y, t); + } + } + return data; +} + +void InverseSearchRadiusOperation::executePixel(float *color, int x, int y, MemoryBuffer *inputBuffers[], void *data) +{ + MemoryBuffer *buffer = (MemoryBuffer*)data; + buffer->read(color, x, y); +} + +void InverseSearchRadiusOperation::deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data) +{ + if (data) { + MemoryBuffer* mb = (MemoryBuffer*)data; + delete mb; + } +} + +void InverseSearchRadiusOperation::deinitExecution() +{ + this->inputRadius = NULL; + this->inputDepth = NULL; +} + +void InverseSearchRadiusOperation::determineResolution(unsigned int resolution[], unsigned int preferredResolution[]) +{ + NodeOperation::determineResolution(resolution, preferredResolution); + resolution[0] = resolution[0] / DIVIDER; + resolution[1] = resolution[1] / DIVIDER; +} + +bool InverseSearchRadiusOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) +{ + rcti newRect; + newRect.ymin = input->ymin*DIVIDER; + newRect.ymax = input->ymax*DIVIDER; + newRect.xmin = input->xmin*DIVIDER; + newRect.xmax = input->xmax*DIVIDER; + return NodeOperation::determineDependingAreaOfInterest(&newRect, readOperation, output); +} +#endif diff --git a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h index 8e59a43fcb1..4bf597ff831 100644 --- a/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h +++ b/source/blender/compositor/operations/COM_VariableSizeBokehBlurOperation.h @@ -25,6 +25,7 @@ #include "COM_NodeOperation.h" #include "COM_QualityStepHelper.h" + class VariableSizeBokehBlurOperation : public NodeOperation, public QualityStepHelper { private: int m_maxBlur; @@ -33,6 +34,9 @@ private: SocketReader *m_inputBokehProgram; SocketReader *m_inputSizeProgram; SocketReader *m_inputDepthProgram; +#ifdef COM_DEFOCUS_SEARCH + SocketReader *inputSearchProgram; +#endif public: VariableSizeBokehBlurOperation(); @@ -60,4 +64,42 @@ public: }; + +#ifdef COM_DEFOCUS_SEARCH +class InverseSearchRadiusOperation : public NodeOperation { +private: + int maxBlur; + float threshold; + SocketReader *inputDepth; + SocketReader *inputRadius; +public: + static const int DIVIDER = 4; + + InverseSearchRadiusOperation(); + + /** + * the inner loop of this program + */ + void executePixel(float *color, int x, int y, MemoryBuffer * inputBuffers[], void *data); + + /** + * Initialize the execution + */ + void initExecution(); + void* initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers); + void deinitializeTileData(rcti *rect, MemoryBuffer **memoryBuffers, void *data); + + /** + * Deinitialize the execution + */ + void deinitExecution(); + + bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output); + void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]); + + void setMaxBlur(int maxRadius) { this->maxBlur = maxRadius; } + + void setThreshold(float threshold) { this->threshold = threshold; } +}; +#endif #endif diff --git a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp index 7259db34134..b8c7478b2f7 100644 --- a/source/blender/compositor/operations/COM_WriteBufferOperation.cpp +++ b/source/blender/compositor/operations/COM_WriteBufferOperation.cpp @@ -63,6 +63,9 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me MemoryBuffer *memoryBuffer = this->m_memoryProxy->getBuffer(); float *buffer = memoryBuffer->getBuffer(); if (this->m_input->isComplex()) { + bNode* bnode = this->m_input->getbNode(); + if (bnode&& bnode->original) bnode->original->highlight++; + void *data = this->m_input->initializeTileData(rect, memoryBuffers); int x1 = rect->xmin; int y1 = rect->ymin; @@ -87,6 +90,7 @@ void WriteBufferOperation::executeRegion(rcti *rect, unsigned int tileNumber, Me this->m_input->deinitializeTileData(rect, memoryBuffers, data); data = NULL; } + if (bnode&& bnode->original) bnode->original->highlight++; } else { int x1 = rect->xmin; @@ -139,6 +143,8 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect, list<cl_mem> *clMemToCleanUp = new list<cl_mem>(); clMemToCleanUp->push_back(clOutputBuffer); list<cl_kernel> *clKernelsToCleanUp = new list<cl_kernel>(); + bNode* bnode = this->m_input->getbNode(); + if (bnode&& bnode->original) bnode->original->highlight++; this->m_input->executeOpenCL(device, outputBuffer, clOutputBuffer, inputMemoryBuffers, clMemToCleanUp, clKernelsToCleanUp); @@ -156,7 +162,8 @@ void WriteBufferOperation::executeOpenCLRegion(OpenCLDevice* device, rcti *rect, if (error != CL_SUCCESS) { printf("CLERROR[%d]: %s\n", error, clewErrorString(error)); } this->getMemoryProxy()->getBuffer()->copyContentFrom(outputBuffer); - + + if (bnode&& bnode->original) bnode->original->highlight++; // STEP 4 diff --git a/source/blender/compositor/operations/COM_ZCombineOperation.h b/source/blender/compositor/operations/COM_ZCombineOperation.h index 2ade3f599ad..422a946b98f 100644 --- a/source/blender/compositor/operations/COM_ZCombineOperation.h +++ b/source/blender/compositor/operations/COM_ZCombineOperation.h @@ -26,8 +26,8 @@ /** - * this program converts an input colour to an output value. - * it assumes we are in sRGB colour space. + * this program converts an input color to an output value. + * it assumes we are in sRGB color space. */ class ZCombineOperation : public NodeOperation { protected: |