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_LensDistortionNode.cpp6
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp33
-rw-r--r--source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h5
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp49
-rw-r--r--source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h4
5 files changed, 69 insertions, 28 deletions
diff --git a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
index 03034e34eb7..0319e66ee22 100644
--- a/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
+++ b/source/blender/compositor/nodes/COM_LensDistortionNode.cpp
@@ -39,7 +39,7 @@ void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorC
ProjectorLensDistortionOperation *operation = new ProjectorLensDistortionOperation();
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- operation->setDispertion(this->getInputSocket(2)->getStaticValues()[0]);
+ this->getInputSocket(2)->relinkConnections(operation->getInputSocket(1), 2, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
operation->setData(data);
@@ -50,8 +50,8 @@ void LensDistortionNode::convertToOperations(ExecutionSystem *graph, CompositorC
ScreenLensDistortionOperation *operation = new ScreenLensDistortionOperation();
this->getInputSocket(0)->relinkConnections(operation->getInputSocket(0), 0, graph);
- operation->setDistortion(this->getInputSocket(1)->getStaticValues()[0]);
- operation->setDispertion(this->getInputSocket(2)->getStaticValues()[0]);
+ this->getInputSocket(1)->relinkConnections(operation->getInputSocket(1), 1, graph);
+ this->getInputSocket(2)->relinkConnections(operation->getInputSocket(2), 2, graph);
this->getOutputSocket(0)->relinkConnections(operation->getOutputSocket(0));
operation->setData(data);
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
index 77f2a06b29b..b337e435df4 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.cpp
@@ -27,19 +27,21 @@
ProjectorLensDistortionOperation::ProjectorLensDistortionOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true);
this->inputProgram = NULL;
+ this->dispersionAvailable = false;
+ this->dispersion = 0.0f;
}
void ProjectorLensDistortionOperation::initExecution()
{
this->inputProgram = this->getInputSocketReader(0);
- kr = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f);
- kr2 = kr * 20;
}
void *ProjectorLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
{
+ updateDispersion(memoryBuffers);
void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers);
return buffer;
}
@@ -69,9 +71,28 @@ void ProjectorLensDistortionOperation::deinitExecution()
bool ProjectorLensDistortionOperation::determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output)
{
rcti newInput;
- newInput.ymax = input->ymax;
- newInput.ymin = input->ymin;
- newInput.xmin = input->xmin - kr2 - 2;
- newInput.xmax = input->xmax + kr2 + 2;
+ if (dispersionAvailable) {
+ newInput.ymax = input->ymax;
+ newInput.ymin = input->ymin;
+ newInput.xmin = input->xmin - kr2 - 2;
+ newInput.xmax = input->xmax + kr2 + 2;
+ } else {
+ newInput.xmin = 0;
+ newInput.ymin = input->ymin;
+ newInput.ymax = input->ymax;
+ newInput.xmax = inputProgram->getWidth();
+ }
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
+
+void ProjectorLensDistortionOperation::updateDispersion(MemoryBuffer **inputBuffers)
+{
+ if (!dispersionAvailable) {
+ float result[4];
+ this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers);
+ dispersion = result[0];
+ kr = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f);
+ kr2 = kr * 20;
+ dispersionAvailable = true;
+ }
+}
diff --git a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
index 2e188617ab5..5023a5df507 100644
--- a/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_ProjectorLensDistortionOperation.h
@@ -35,6 +35,8 @@ private:
NodeLensDist *data;
float dispersion;
+ bool dispersionAvailable;
+
float kr, kr2;
public:
ProjectorLensDistortionOperation();
@@ -56,9 +58,10 @@ public:
void deinitExecution();
void setData(NodeLensDist *data) { this->data = data; }
- void setDispertion(float dispersion) { this->dispersion = dispersion; }
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
+ void updateDispersion(MemoryBuffer** inputBuffers);
+
};
#endif
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
index 02cc62d4bdd..da3504de971 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp
@@ -30,34 +30,24 @@ extern "C" {
ScreenLensDistortionOperation::ScreenLensDistortionOperation() : NodeOperation()
{
this->addInputSocket(COM_DT_COLOR);
+ this->addInputSocket(COM_DT_VALUE);
+ this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true);
this->inputProgram = NULL;
+ this->valuesAvailable = false;
+ this->dispersion = 0.0f;
+ this->distortion = 0.0f;
}
void ScreenLensDistortionOperation::initExecution()
{
this->inputProgram = this->getInputSocketReader(0);
- kg = MAX2(MIN2(this->distortion, 1.f), -0.999f);
- // smaller dispersion range for somewhat more control
- const float d = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f);
- kr = MAX2(MIN2((kg + d), 1.f), -0.999f);
- kb = MAX2(MIN2((kg - d), 1.f), -0.999f);
- maxk = MAX3(kr, kg, kb);
- sc = (this->data->fit && (maxk > 0.f)) ? (1.f / (1.f + 2.f * maxk)) : (1.f / (1.f + maxk));
- drg = 4.f * (kg - kr);
- dgb = 4.f * (kb - kg);
-
- kr4 = kr * 4.f;
- kg4 = kg * 4.f;
- kb4 = kb * 4.f;
- cx = 0.5f * (float)getWidth();
- cy = 0.5f * (float)getHeight();
-
}
void *ScreenLensDistortionOperation::initializeTileData(rcti *rect, MemoryBuffer **memoryBuffers)
{
void *buffer = inputProgram->initializeTileData(NULL, memoryBuffers);
+ updateDispersionAndDistortion(memoryBuffers);
return buffer;
}
@@ -171,3 +161,30 @@ bool ScreenLensDistortionOperation::determineDependingAreaOfInterest(rcti *input
newInput.xmax = inputProgram->getWidth();
return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output);
}
+
+void ScreenLensDistortionOperation::updateDispersionAndDistortion(MemoryBuffer **inputBuffers)
+{
+ if (!valuesAvailable) {
+ float result[4];
+ this->getInputSocketReader(1)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers);
+ this->distortion = result[0];
+ this->getInputSocketReader(2)->read(result, 0, 0, COM_PS_NEAREST, inputBuffers);
+ this->dispersion = result[0];
+ kg = MAX2(MIN2(this->distortion, 1.f), -0.999f);
+ // smaller dispersion range for somewhat more control
+ const float d = 0.25f * MAX2(MIN2(this->dispersion, 1.f), 0.f);
+ kr = MAX2(MIN2((kg + d), 1.f), -0.999f);
+ kb = MAX2(MIN2((kg - d), 1.f), -0.999f);
+ maxk = MAX3(kr, kg, kb);
+ sc = (this->data->fit && (maxk > 0.f)) ? (1.f / (1.f + 2.f * maxk)) : (1.f / (1.f + maxk));
+ drg = 4.f * (kg - kr);
+ dgb = 4.f * (kb - kg);
+
+ kr4 = kr * 4.f;
+ kg4 = kg * 4.f;
+ kb4 = kb * 4.f;
+ cx = 0.5f * (float)getWidth();
+ cy = 0.5f * (float)getHeight();
+ valuesAvailable = true;
+ }
+}
diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
index 34656f38a09..21babd11295 100644
--- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
+++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.h
@@ -36,6 +36,7 @@ private:
float dispersion;
float distortion;
+ bool valuesAvailable;
float kr, kg, kb;
float kr4, kg4, kb4;
float maxk;
@@ -62,13 +63,12 @@ public:
void deinitExecution();
void setData(NodeLensDist *data) { this->data = data; }
- void setDispertion(float dispersion) { this->dispersion = dispersion; }
- void setDistortion(float distortion) { this->distortion = distortion; }
bool determineDependingAreaOfInterest(rcti *input, ReadBufferOperation *readOperation, rcti *output);
private:
void determineUV(float *result, float x, float y) const;
+ void updateDispersionAndDistortion(MemoryBuffer** inputBuffers);
};
#endif