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-11-17 10:14:25 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2012-11-17 10:14:25 +0400
commitc063194c6a65b396145e21c1786c810b05c7032a (patch)
treecc6c322775048bc3135abbe2903461cf54540ecd /source/blender/compositor
parent3b008503ab4dc6de7893806408e77f5ae63bccf5 (diff)
Fix #33204: Blur node ignores Gamma setting
Gamma correction option was ignored by new compositor system. Also new compositor was doing alpha premul in a wrong way. In fact, not sure if it should do premul -- old compositor didn't do that..
Diffstat (limited to 'source/blender/compositor')
-rw-r--r--source/blender/compositor/nodes/COM_BlurNode.cpp48
-rw-r--r--source/blender/compositor/operations/COM_GammaCorrectOperation.cpp26
2 files changed, 45 insertions, 29 deletions
diff --git a/source/blender/compositor/nodes/COM_BlurNode.cpp b/source/blender/compositor/nodes/COM_BlurNode.cpp
index 4f120ea5a6e..6a4987c2075 100644
--- a/source/blender/compositor/nodes/COM_BlurNode.cpp
+++ b/source/blender/compositor/nodes/COM_BlurNode.cpp
@@ -31,6 +31,7 @@
#include "COM_FastGaussianBlurOperation.h"
#include "COM_MathBaseOperation.h"
#include "COM_SetValueOperation.h"
+#include "COM_GammaCorrectOperation.h"
BlurNode::BlurNode(bNode *editorNode) : Node(editorNode)
{
@@ -48,16 +49,17 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
const float size = ((const bNodeSocketValueFloat *)sock->default_value)->value;
CompositorQuality quality = context->getQuality();
-
+ NodeOperation *input_operation = NULL, *output_operation = NULL;
+
if (data->filtertype == R_FILTER_FAST_GAUSS) {
FastGaussianBlurOperation *operationfgb = new FastGaussianBlurOperation();
operationfgb->setData(data);
operationfgb->setbNode(editorNode);
- this->getInputSocket(0)->relinkConnections(operationfgb->getInputSocket(0), 0, graph);
this->getInputSocket(1)->relinkConnections(operationfgb->getInputSocket(1), 1, graph);
- this->getOutputSocket(0)->relinkConnections(operationfgb->getOutputSocket(0));
graph->addOperation(operationfgb);
- addPreviewOperation(graph, context, operationfgb->getOutputSocket());
+
+ input_operation = operationfgb;
+ output_operation = operationfgb;
}
else if (editorNode->custom1 & CMP_NODEFLAG_BLUR_VARIABLE_SIZE) {
MathAddOperation *clamp = new MathAddOperation();
@@ -93,48 +95,68 @@ void BlurNode::convertToOperations(ExecutionSystem *graph, CompositorContext *co
operation->setData(data);
operation->setbNode(editorNode);
operation->setQuality(quality);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
addLink(graph, operationy->getOutputSocket(), operation->getInputSocket(1));
graph->addOperation(operation);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
- addPreviewOperation(graph, context, operation->getOutputSocket());
+
+ output_operation = operation;
+ input_operation = operation;
}
else if (!data->bokeh) {
GaussianXBlurOperation *operationx = new GaussianXBlurOperation();
operationx->setData(data);
operationx->setbNode(editorNode);
operationx->setQuality(quality);
- this->getInputSocket(0)->relinkConnections(operationx->getInputSocket(0), 0, graph);
this->getInputSocket(1)->relinkConnections(operationx->getInputSocket(1), 1, graph);
graph->addOperation(operationx);
GaussianYBlurOperation *operationy = new GaussianYBlurOperation();
operationy->setData(data);
operationy->setbNode(editorNode);
operationy->setQuality(quality);
- this->getOutputSocket(0)->relinkConnections(operationy->getOutputSocket());
+
graph->addOperation(operationy);
addLink(graph, operationx->getOutputSocket(), operationy->getInputSocket(0));
addLink(graph, operationx->getInputSocket(1)->getConnection()->getFromSocket(), operationy->getInputSocket(1));
- addPreviewOperation(graph, context, operationy->getOutputSocket());
if (!connectedSizeSocket) {
operationx->setSize(size);
operationy->setSize(size);
}
+
+ input_operation = operationx;
+ output_operation = operationy;
}
else {
GaussianBokehBlurOperation *operation = new GaussianBokehBlurOperation();
operation->setData(data);
operation->setbNode(editorNode);
- this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
operation->setQuality(quality);
graph->addOperation(operation);
- this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket());
- addPreviewOperation(graph, context, operation->getOutputSocket());
if (!connectedSizeSocket) {
operation->setSize(size);
}
+
+ input_operation = operation;
+ output_operation = operation;
+ }
+
+ if (data->gamma) {
+ GammaCorrectOperation *correct = new GammaCorrectOperation();
+ GammaUncorrectOperation *inverse = new GammaUncorrectOperation();
+
+ this->getInputSocket(0)->relinkConnections(correct->getInputSocket(0), 0, graph);
+ addLink(graph, correct->getOutputSocket(), input_operation->getInputSocket(0));
+ addLink(graph, output_operation->getOutputSocket(), inverse->getInputSocket(0));
+ this->getOutputSocket()->relinkConnections(inverse->getOutputSocket());
+ graph->addOperation(correct);
+ graph->addOperation(inverse);
+
+ addPreviewOperation(graph, context, inverse->getOutputSocket());
+ }
+ else {
+ this->getInputSocket(0)->relinkConnections(input_operation->getInputSocket(0), 0, graph);
+ this->getOutputSocket()->relinkConnections(output_operation->getOutputSocket());
+ addPreviewOperation(graph, context, output_operation->getOutputSocket());
}
}
diff --git a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
index af990f4f3e0..c36a6f896c2 100644
--- a/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
+++ b/source/blender/compositor/operations/COM_GammaCorrectOperation.cpp
@@ -49,14 +49,11 @@ void GammaCorrectOperation::executePixel(float output[4], float x, float y, Pixe
output[1] = inputColor[1] > 0.0f ? inputColor[1] * inputColor[1] : 0.0f;
output[2] = inputColor[2] > 0.0f ? inputColor[2] * inputColor[2] : 0.0f;
- inputColor[0] *= inputColor[3];
- inputColor[1] *= inputColor[3];
- inputColor[2] *= inputColor[3];
-
- output[0] = inputColor[0];
- output[1] = inputColor[1];
- output[2] = inputColor[2];
- output[3] = inputColor[3];
+ if (inputColor[3] > 0.0f) {
+ output[0] *= inputColor[3];
+ output[1] *= inputColor[3];
+ output[2] *= inputColor[3];
+ }
}
void GammaCorrectOperation::deinitExecution()
@@ -90,14 +87,11 @@ void GammaUncorrectOperation::executePixel(float output[4], float x, float y, Pi
output[1] = inputColor[1] > 0.0f ? sqrtf(inputColor[1]) : 0.0f;
output[2] = inputColor[2] > 0.0f ? sqrtf(inputColor[2]) : 0.0f;
- inputColor[0] *= inputColor[3];
- inputColor[1] *= inputColor[3];
- inputColor[2] *= inputColor[3];
-
- output[0] = inputColor[0];
- output[1] = inputColor[1];
- output[2] = inputColor[2];
- output[3] = inputColor[3];
+ if (inputColor[3] > 0.0f) {
+ output[0] *= inputColor[3];
+ output[1] *= inputColor[3];
+ output[2] *= inputColor[3];
+ }
}
void GammaUncorrectOperation::deinitExecution()