Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2012-07-10 13:12:33 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-07-10 13:12:33 +0400
commit717ac64cb14b09660419cc4fa8b48e47ccacd854 (patch)
tree26393b4ccff0b4e9dbd580aec78a270649992da6 /source/blender/compositor/operations/COM_MathBaseOperation.cpp
parent63ad458dbafe9cecc8568fd4779b7568d06b81b2 (diff)
Tomato: added option to clamp result of Mix RGB and Color Math nodes
Diffstat (limited to 'source/blender/compositor/operations/COM_MathBaseOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_MathBaseOperation.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/source/blender/compositor/operations/COM_MathBaseOperation.cpp b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
index 1bf89be57b5..596895a963a 100644
--- a/source/blender/compositor/operations/COM_MathBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_MathBaseOperation.cpp
@@ -64,6 +64,13 @@ void MathBaseOperation::determineResolution(unsigned int resolution[], unsigned
NodeOperation::determineResolution(resolution, preferredResolution);
}
+void MathBaseOperation::clampIfNeeded(float *color)
+{
+ if (this->m_useClamp) {
+ CLAMP(color[0], 0.0f, 1.0f);
+ }
+}
+
void MathAddOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
{
float inputValue1[4];
@@ -73,6 +80,8 @@ void MathAddOperation::executePixel(float *outputValue, float x, float y, PixelS
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
outputValue[0] = inputValue1[0] + inputValue2[0];
+
+ clampIfNeeded(outputValue);
}
void MathSubtractOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -84,6 +93,8 @@ void MathSubtractOperation::executePixel(float *outputValue, float x, float y, P
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
outputValue[0] = inputValue1[0] - inputValue2[0];
+
+ clampIfNeeded(outputValue);
}
void MathMultiplyOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -95,6 +106,8 @@ void MathMultiplyOperation::executePixel(float *outputValue, float x, float y, P
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
outputValue[0] = inputValue1[0] * inputValue2[0];
+
+ clampIfNeeded(outputValue);
}
void MathDivideOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -109,6 +122,8 @@ void MathDivideOperation::executePixel(float *outputValue, float x, float y, Pix
outputValue[0] = 0.0;
else
outputValue[0] = inputValue1[0] / inputValue2[0];
+
+ clampIfNeeded(outputValue);
}
void MathSineOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -120,6 +135,8 @@ void MathSineOperation::executePixel(float *outputValue, float x, float y, Pixel
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
outputValue[0] = sin(inputValue1[0]);
+
+ clampIfNeeded(outputValue);
}
void MathCosineOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -131,6 +148,8 @@ void MathCosineOperation::executePixel(float *outputValue, float x, float y, Pix
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
outputValue[0] = cos(inputValue1[0]);
+
+ clampIfNeeded(outputValue);
}
void MathTangentOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -142,6 +161,8 @@ void MathTangentOperation::executePixel(float *outputValue, float x, float y, Pi
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
outputValue[0] = tan(inputValue1[0]);
+
+ clampIfNeeded(outputValue);
}
void MathArcSineOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -156,6 +177,8 @@ void MathArcSineOperation::executePixel(float *outputValue, float x, float y, Pi
outputValue[0] = asin(inputValue1[0]);
else
outputValue[0] = 0.0;
+
+ clampIfNeeded(outputValue);
}
void MathArcCosineOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -170,6 +193,8 @@ void MathArcCosineOperation::executePixel(float *outputValue, float x, float y,
outputValue[0] = acos(inputValue1[0]);
else
outputValue[0] = 0.0;
+
+ clampIfNeeded(outputValue);
}
void MathArcTangentOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -181,6 +206,8 @@ void MathArcTangentOperation::executePixel(float *outputValue, float x, float y,
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
outputValue[0] = atan(inputValue1[0]);
+
+ clampIfNeeded(outputValue);
}
void MathPowerOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -204,6 +231,8 @@ void MathPowerOperation::executePixel(float *outputValue, float x, float y, Pixe
outputValue[0] = 0.0;
}
}
+
+ clampIfNeeded(outputValue);
}
void MathLogarithmOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -218,6 +247,8 @@ void MathLogarithmOperation::executePixel(float *outputValue, float x, float y,
outputValue[0] = log(inputValue1[0]) / log(inputValue2[0]);
else
outputValue[0] = 0.0;
+
+ clampIfNeeded(outputValue);
}
void MathMinimumOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -229,6 +260,8 @@ void MathMinimumOperation::executePixel(float *outputValue, float x, float y, Pi
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
outputValue[0] = min(inputValue1[0], inputValue2[0]);
+
+ clampIfNeeded(outputValue);
}
void MathMaximumOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -240,6 +273,8 @@ void MathMaximumOperation::executePixel(float *outputValue, float x, float y, Pi
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
outputValue[0] = max(inputValue1[0], inputValue2[0]);
+
+ clampIfNeeded(outputValue);
}
void MathRoundOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -251,6 +286,8 @@ void MathRoundOperation::executePixel(float *outputValue, float x, float y, Pixe
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
outputValue[0] = round(inputValue1[0]);
+
+ clampIfNeeded(outputValue);
}
void MathLessThanOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -262,6 +299,8 @@ void MathLessThanOperation::executePixel(float *outputValue, float x, float y, P
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
outputValue[0] = inputValue1[0] < inputValue2[0] ? 1.0f : 0.0f;
+
+ clampIfNeeded(outputValue);
}
void MathGreaterThanOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -273,6 +312,8 @@ void MathGreaterThanOperation::executePixel(float *outputValue, float x, float y
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
outputValue[0] = inputValue1[0] > inputValue2[0] ? 1.0f : 0.0f;
+
+ clampIfNeeded(outputValue);
}