diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2012-06-22 18:43:25 +0400 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2012-06-22 18:43:25 +0400 |
commit | 590f5fdbdfc2357c5b0490a406c9c39cf66de50a (patch) | |
tree | 63b756081f9c13c1e9549b4c8df9793d5b9b547a /source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp | |
parent | 65e9216ccea172ee09da0a5ecc6515d7b4c5e443 (diff) |
fix for [#31890] Lens Distortion inside Node group don't work
Diffstat (limited to 'source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp')
-rw-r--r-- | source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp | 49 |
1 files changed, 33 insertions, 16 deletions
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; + } +} |