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:
Diffstat (limited to 'source/blender/compositor')
-rw-r--r--source/blender/compositor/nodes/COM_KeyingNode.cpp7
-rw-r--r--source/blender/compositor/nodes/COM_KeyingNode.h3
-rw-r--r--source/blender/compositor/operations/COM_KeyingDespillOperation.cpp13
-rw-r--r--source/blender/compositor/operations/COM_KeyingDespillOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_KeyingOperation.cpp7
5 files changed, 23 insertions, 9 deletions
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.cpp b/source/blender/compositor/nodes/COM_KeyingNode.cpp
index 7c39765fbf1..efd50a44a51 100644
--- a/source/blender/compositor/nodes/COM_KeyingNode.cpp
+++ b/source/blender/compositor/nodes/COM_KeyingNode.cpp
@@ -184,11 +184,13 @@ OutputSocket *KeyingNode::setupFeather(ExecutionSystem *graph, CompositorContext
return operationy->getOutputSocket();
}
-OutputSocket *KeyingNode::setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputScreen, float factor)
+OutputSocket *KeyingNode::setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputScreen,
+ float factor, float colorBalance)
{
KeyingDespillOperation *despillOperation = new KeyingDespillOperation();
despillOperation->setDespillFactor(factor);
+ despillOperation->setColorBalance(colorBalance);
addLink(graph, despillInput, despillOperation->getInputSocket(0));
addLink(graph, inputScreen, despillOperation->getInputSocket(1));
@@ -292,7 +294,8 @@ void KeyingNode::convertToOperations(ExecutionSystem *graph, CompositorContext *
if (keying_data->despill_factor > 0.0f) {
postprocessedImage = setupDespill(graph, postprocessedImage,
keyingOperation->getInputSocket(1)->getConnection()->getFromSocket(),
- keying_data->despill_factor);
+ keying_data->despill_factor,
+ keying_data->despill_balance);
}
/* connect result to output sockets */
diff --git a/source/blender/compositor/nodes/COM_KeyingNode.h b/source/blender/compositor/nodes/COM_KeyingNode.h
index 294a27bb52c..6ab6a60a44d 100644
--- a/source/blender/compositor/nodes/COM_KeyingNode.h
+++ b/source/blender/compositor/nodes/COM_KeyingNode.h
@@ -36,7 +36,8 @@ protected:
OutputSocket *setupDilateErode(ExecutionSystem *graph, OutputSocket *dilateErodeInput, int distance);
OutputSocket *setupFeather(ExecutionSystem *graph, CompositorContext *context, OutputSocket *featherInput,
int falloff, int distance);
- OutputSocket *setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputSrceen, float factor);
+ OutputSocket *setupDespill(ExecutionSystem *graph, OutputSocket *despillInput, OutputSocket *inputSrceen,
+ float factor, float colorBalance);
OutputSocket *setupClip(ExecutionSystem *graph, OutputSocket *clipInput, int kernelRadius, float kernelTolerance,
float clipBlack, float clipWhite, bool edgeMatte);
public:
diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
index 081d9f723e8..9798ddcee94 100644
--- a/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.cpp
@@ -47,6 +47,7 @@ KeyingDespillOperation::KeyingDespillOperation() : NodeOperation()
this->addOutputSocket(COM_DT_COLOR);
this->m_despillFactor = 0.5f;
+ this->m_colorBalance = 0.5f;
this->m_pixelReader = NULL;
this->m_screenReader = NULL;
@@ -73,16 +74,22 @@ void KeyingDespillOperation::executePixel(float *color, float x, float y, PixelS
this->m_screenReader->read(screenColor, x, y, sampler, inputBuffers);
int screen_primary_channel = get_pixel_primary_channel(screenColor);
+ int other_1 = (screen_primary_channel + 1) % 3;
+ int other_2 = (screen_primary_channel + 2) % 3;
+
+ int min_channel = MIN2(other_1, other_2);
+ int max_channel = MAX2(other_1, other_2);
+
float average_value, amount;
- average_value = (pixelColor[0] + pixelColor[1] + pixelColor[2] - pixelColor[screen_primary_channel]) / 2.0f;
- amount = pixelColor[screen_primary_channel] - average_value;
+ average_value = this->m_colorBalance * pixelColor[min_channel] + (1.0f - this->m_colorBalance) * pixelColor[max_channel];
+ amount = (pixelColor[screen_primary_channel] - average_value);
color[0] = pixelColor[0];
color[1] = pixelColor[1];
color[2] = pixelColor[2];
color[3] = pixelColor[3];
-
+
if (this->m_despillFactor * amount > 0) {
color[screen_primary_channel] = pixelColor[screen_primary_channel] - this->m_despillFactor * amount;
}
diff --git a/source/blender/compositor/operations/COM_KeyingDespillOperation.h b/source/blender/compositor/operations/COM_KeyingDespillOperation.h
index 4fea9b578a1..3485bf1952f 100644
--- a/source/blender/compositor/operations/COM_KeyingDespillOperation.h
+++ b/source/blender/compositor/operations/COM_KeyingDespillOperation.h
@@ -34,6 +34,7 @@ protected:
SocketReader *m_pixelReader;
SocketReader *m_screenReader;
float m_despillFactor;
+ float m_colorBalance;
public:
KeyingDespillOperation();
@@ -42,6 +43,7 @@ public:
void deinitExecution();
void setDespillFactor(float value) {this->m_despillFactor = value;}
+ void setColorBalance(float value) {this->m_colorBalance = value;}
void executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]);
};
diff --git a/source/blender/compositor/operations/COM_KeyingOperation.cpp b/source/blender/compositor/operations/COM_KeyingOperation.cpp
index e92e5c84c2d..48d1967b5b3 100644
--- a/source/blender/compositor/operations/COM_KeyingOperation.cpp
+++ b/source/blender/compositor/operations/COM_KeyingOperation.cpp
@@ -45,9 +45,10 @@ static float get_pixel_saturation(float pixelColor[4], float screen_balance, int
int other_1 = (primary_channel + 1) % 3;
int other_2 = (primary_channel + 2) % 3;
- float min = MIN2(pixelColor[other_1], pixelColor[other_2]);
- float max = MAX2(pixelColor[other_1], pixelColor[other_2]);
- float val = screen_balance * min + (1.0f - screen_balance) * max;
+ int min_channel = MIN2(other_1, other_2);
+ int max_channel = MAX2(other_1, other_2);
+
+ float val = screen_balance * pixelColor[min_channel] + (1.0f - screen_balance) * pixelColor[max_channel];
return (pixelColor[primary_channel] - val) * fabsf(1.0f - val);
}