[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48798] trunk/blender: Mango request: option to clamp result of Mix RGB and Color Math nodes
Sergey Sharybin
sergey.vfx at gmail.com
Tue Jul 10 12:36:18 CEST 2012
Revision: 48798
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48798
Author: nazgul
Date: 2012-07-10 10:36:18 +0000 (Tue, 10 Jul 2012)
Log Message:
-----------
Mango request: option to clamp result of Mix RGB and Color Math nodes
---
Merging r48792 from soc-2011-tomato into trunk
Revision Links:
--------------
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48792
Modified Paths:
--------------
trunk/blender/source/blender/compositor/nodes/COM_MathNode.cpp
trunk/blender/source/blender/compositor/nodes/COM_MixNode.cpp
trunk/blender/source/blender/compositor/operations/COM_MathBaseOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MathBaseOperation.h
trunk/blender/source/blender/compositor/operations/COM_MixAddOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixBaseOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixBaseOperation.h
trunk/blender/source/blender/compositor/operations/COM_MixBlendOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixBurnOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixColorOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixDarkenOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixDifferenceOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixDivideOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixDodgeOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixGlareOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixHueOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixLightenOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixLinearLightOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixMultiplyOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixOverlayOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixSaturationOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixScreenOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixSoftLightOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixSubtractOperation.cpp
trunk/blender/source/blender/compositor/operations/COM_MixValueOperation.cpp
trunk/blender/source/blender/editors/space_node/drawnode.c
trunk/blender/source/blender/makesrna/intern/rna_nodetree.c
Property Changed:
----------------
trunk/blender/
trunk/blender/source/blender/editors/interface/interface.c
trunk/blender/source/blender/editors/space_outliner/
Property changes on: trunk/blender
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48793
+ /branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48792-48793
Modified: trunk/blender/source/blender/compositor/nodes/COM_MathNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_MathNode.cpp 2012-07-10 10:31:05 UTC (rev 48797)
+++ trunk/blender/source/blender/compositor/nodes/COM_MathNode.cpp 2012-07-10 10:36:18 UTC (rev 48798)
@@ -83,10 +83,14 @@
}
if (operation != NULL) {
+ bool useClamp = this->getbNode()->custom2;
+
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
-
+
+ operation->setUseClamp(useClamp);
+
graph->addOperation(operation);
}
}
Modified: trunk/blender/source/blender/compositor/nodes/COM_MixNode.cpp
===================================================================
--- trunk/blender/source/blender/compositor/nodes/COM_MixNode.cpp 2012-07-10 10:31:05 UTC (rev 48797)
+++ trunk/blender/source/blender/compositor/nodes/COM_MixNode.cpp 2012-07-10 10:36:18 UTC (rev 48798)
@@ -58,6 +58,8 @@
InputSocket *color2Socket = this->getInputSocket(2);
OutputSocket *outputSocket = this->getOutputSocket(0);
bNode *editorNode = this->getbNode();
+ bool useAlphaPremultiply = this->getbNode()->custom2 & 1;
+ bool useClamp = this->getbNode()->custom2 & 2;
MixBaseOperation *convertProg;
@@ -119,7 +121,8 @@
convertProg = new MixBlendOperation();
break;
}
- convertProg->setUseValueAlphaMultiply(this->getbNode()->custom2);
+ convertProg->setUseValueAlphaMultiply(useAlphaPremultiply);
+ convertProg->setUseClamp(useClamp);
valueSocket->relinkConnections(convertProg->getInputSocket(0), 0, graph);
color1Socket->relinkConnections(convertProg->getInputSocket(1), 1, graph);
Modified: trunk/blender/source/blender/compositor/operations/COM_MathBaseOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_MathBaseOperation.cpp 2012-07-10 10:31:05 UTC (rev 48797)
+++ trunk/blender/source/blender/compositor/operations/COM_MathBaseOperation.cpp 2012-07-10 10:36:18 UTC (rev 48798)
@@ -64,6 +64,13 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
outputValue[0] = 0.0;
}
}
+
+ clampIfNeeded(outputValue);
}
void MathLogarithmOperation::executePixel(float *outputValue, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
@@ -218,6 +247,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
this->m_inputValue2Operation->read(&inputValue2[0], x, y, sampler, inputBuffers);
outputValue[0] = inputValue1[0] > inputValue2[0] ? 1.0f : 0.0f;
+
+ clampIfNeeded(outputValue);
}
Modified: trunk/blender/source/blender/compositor/operations/COM_MathBaseOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_MathBaseOperation.h 2012-07-10 10:31:05 UTC (rev 48797)
+++ trunk/blender/source/blender/compositor/operations/COM_MathBaseOperation.h 2012-07-10 10:36:18 UTC (rev 48798)
@@ -37,11 +37,15 @@
SocketReader *m_inputValue1Operation;
SocketReader *m_inputValue2Operation;
+ bool m_useClamp;
+
protected:
/**
* Default constructor
*/
MathBaseOperation();
+
+ void clampIfNeeded(float *color);
public:
/**
* the inner loop of this program
@@ -62,6 +66,8 @@
* Determine resolution
*/
void determineResolution(unsigned int resolution[], unsigned int preferredResolution[]);
+
+ void setUseClamp(bool value) { this->m_useClamp = value; }
};
class MathAddOperation : public MathBaseOperation {
Modified: trunk/blender/source/blender/compositor/operations/COM_MixAddOperation.cpp
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_MixAddOperation.cpp 2012-07-10 10:31:05 UTC (rev 48797)
+++ trunk/blender/source/blender/compositor/operations/COM_MixAddOperation.cpp 2012-07-10 10:36:18 UTC (rev 48798)
@@ -46,5 +46,7 @@
outputValue[1] = inputColor1[1] + value * inputColor2[1];
outputValue[2] = inputColor1[2] + value * inputColor2[2];
outputValue[3] = inputColor1[3];
+
+ clampIfNeeded(outputValue);
}
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list