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/operations/COM_MapUVOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_MapUVOperation.cpp49
1 files changed, 27 insertions, 22 deletions
diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cpp b/source/blender/compositor/operations/COM_MapUVOperation.cpp
index 08790955d03..7b393cc04a8 100644
--- a/source/blender/compositor/operations/COM_MapUVOperation.cpp
+++ b/source/blender/compositor/operations/COM_MapUVOperation.cpp
@@ -22,7 +22,8 @@
#include "COM_MapUVOperation.h"
#include "BLI_math.h"
-MapUVOperation::MapUVOperation(): NodeOperation() {
+MapUVOperation::MapUVOperation(): NodeOperation()
+{
this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(COM_DT_VECTOR);
this->addOutputSocket(COM_DT_COLOR);
@@ -33,12 +34,14 @@ MapUVOperation::MapUVOperation(): NodeOperation() {
this->inputColorProgram = NULL;
}
-void MapUVOperation::initExecution() {
+void MapUVOperation::initExecution()
+{
this->inputColorProgram = this->getInputSocketReader(0);
this->inputUVProgram = this->getInputSocketReader(1);
}
-void MapUVOperation::executePixel(float* color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[]) {
+void MapUVOperation::executePixel(float *color, float x, float y, PixelSampler sampler, MemoryBuffer *inputBuffers[])
+{
float inputUV[4];
float uv_a[4], uv_b[4];
float u,v;
@@ -58,36 +61,36 @@ void MapUVOperation::executePixel(float* color, float x, float y, PixelSampler s
/* adaptive sampling, red (U) channel */
this->inputUVProgram->read(uv_a, x-1, y, COM_PS_NEAREST, inputBuffers);
this->inputUVProgram->read(uv_b, x+1, y, COM_PS_NEAREST, inputBuffers);
- uv_l= uv_a[2]!=0.f? fabs(inputUV[0] - uv_a[0]) : 0.f;
- uv_r= uv_b[2]!=0.f? fabs(inputUV[0] - uv_b[0]) : 0.f;
+ uv_l = uv_a[2]!=0.f? fabs(inputUV[0] - uv_a[0]) : 0.f;
+ uv_r = uv_b[2]!=0.f? fabs(inputUV[0] - uv_b[0]) : 0.f;
- dx= 0.5f * (uv_l + uv_r);
+ dx = 0.5f * (uv_l + uv_r);
/* adaptive sampling, green (V) channel */
this->inputUVProgram->read(uv_a, x, y-1, COM_PS_NEAREST, inputBuffers);
this->inputUVProgram->read(uv_b, x, y+1, COM_PS_NEAREST, inputBuffers);
- uv_u= uv_a[2]!=0.f? fabs(inputUV[1] - uv_a[1]) : 0.f;
- uv_d= uv_b[2]!=0.f? fabs(inputUV[1] - uv_b[1]) : 0.f;
+ uv_u = uv_a[2]!=0.f? fabs(inputUV[1] - uv_a[1]) : 0.f;
+ uv_d = uv_b[2]!=0.f? fabs(inputUV[1] - uv_b[1]) : 0.f;
- dy= 0.5f * (uv_u + uv_d);
+ dy = 0.5f * (uv_u + uv_d);
/* more adaptive sampling, red and green (UV) channels */
this->inputUVProgram->read(uv_a, x-1, y-1, COM_PS_NEAREST, inputBuffers);
this->inputUVProgram->read(uv_b, x-1, y+1, COM_PS_NEAREST, inputBuffers);
- uv_l= uv_a[2]!=0.f? fabsf(inputUV[0] - uv_a[0]) : 0.f;
- uv_r= uv_b[2]!=0.f? fabsf(inputUV[0] - uv_b[0]) : 0.f;
- uv_u= uv_a[2]!=0.f? fabsf(inputUV[1] - uv_a[1]) : 0.f;
- uv_d= uv_b[2]!=0.f? fabsf(inputUV[1] - uv_b[1]) : 0.f;
+ uv_l = uv_a[2]!=0.f? fabsf(inputUV[0] - uv_a[0]) : 0.f;
+ uv_r = uv_b[2]!=0.f? fabsf(inputUV[0] - uv_b[0]) : 0.f;
+ uv_u = uv_a[2]!=0.f? fabsf(inputUV[1] - uv_a[1]) : 0.f;
+ uv_d = uv_b[2]!=0.f? fabsf(inputUV[1] - uv_b[1]) : 0.f;
dx+= 0.25f * (uv_l + uv_r);
dy+= 0.25f * (uv_u + uv_d);
this->inputUVProgram->read(uv_a, x+1, y-1, COM_PS_NEAREST, inputBuffers);
this->inputUVProgram->read(uv_b, x+1, y+1, COM_PS_NEAREST, inputBuffers);
- uv_l= uv_a[2]!=0.f? fabsf(inputUV[0] - uv_a[0]) : 0.f;
- uv_r= uv_b[2]!=0.f? fabsf(inputUV[0] - uv_b[0]) : 0.f;
- uv_u= uv_a[2]!=0.f? fabsf(inputUV[1] - uv_a[1]) : 0.f;
- uv_d= uv_b[2]!=0.f? fabsf(inputUV[1] - uv_b[1]) : 0.f;
+ uv_l = uv_a[2]!=0.f? fabsf(inputUV[0] - uv_a[0]) : 0.f;
+ uv_r = uv_b[2]!=0.f? fabsf(inputUV[0] - uv_b[0]) : 0.f;
+ uv_u = uv_a[2]!=0.f? fabsf(inputUV[1] - uv_a[1]) : 0.f;
+ uv_d = uv_b[2]!=0.f? fabsf(inputUV[1] - uv_b[1]) : 0.f;
dx+= 0.25f * (uv_l + uv_r);
dy+= 0.25f * (uv_u + uv_d);
@@ -95,12 +98,12 @@ void MapUVOperation::executePixel(float* color, float x, float y, PixelSampler s
/* UV to alpha threshold */
const float threshold = this->alpha * 0.05f;
float alpha = 1.0f - threshold * (dx + dy);
- if (alpha < 0.f) alpha= 0.f;
+ if (alpha < 0.f) alpha = 0.f;
else alpha *= inputUV[2];
/* should use mipmap */
- dx= min(dx, 0.2f);
- dy= min(dy, 0.2f);
+ dx = min(dx, 0.2f);
+ dy = min(dy, 0.2f);
/* EWA filtering */
@@ -118,12 +121,14 @@ void MapUVOperation::executePixel(float* color, float x, float y, PixelSampler s
}
}
-void MapUVOperation::deinitExecution() {
+void MapUVOperation::deinitExecution()
+{
this->inputUVProgram = NULL;
this->inputColorProgram = NULL;
}
-bool MapUVOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output) {
+bool MapUVOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
+{
rcti colorInput;
rcti uvInput;
NodeOperation *operation=NULL;