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:
authorLukas Tönne <lukas.toenne@gmail.com>2014-02-13 14:46:15 +0400
committerLukas Tönne <lukas.toenne@gmail.com>2014-02-13 14:52:22 +0400
commit51efa8a1f53f230b72210289483dae66f01de51a (patch)
treea4c478dee85563290c2677cb86c9a12e8878c003 /source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
parent5fdf6169a3ed281c6655fdd1c14ad57fcdb972b9 (diff)
Fix T38529, Blur node size 0 doesn't work.
The blur operations were clamping the filter size to 1, which prevents no-op blur nodes. Further any value < 1 would also be ignored and in many combinations the filter scale setting ("Size") would only work in integer steps. Now most blur settings will work with smooth Size value scaling as well, meaning you can choose a reasonably large filter size (e.g. 10) and then use the Size factor to scale the actual blur radius smoothly. Note that non-integer filter sizes also depend on the filter type selected in the Blur node, e.g. "Flat" filtering will still ignore smooth filter sizes. Gaussian filters work best for this purpose.
Diffstat (limited to 'source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp51
1 files changed, 23 insertions, 28 deletions
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
index 4866fb9b428..fb407bf9ee4 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
@@ -32,7 +32,7 @@ extern "C" {
GaussianAlphaYBlurOperation::GaussianAlphaYBlurOperation() : BlurBaseOperation(COM_DT_VALUE)
{
this->m_gausstab = NULL;
- this->m_rad = 0;
+ this->m_filtersize = 0;
this->m_falloff = -1; /* intentionally invalid, so we can detect uninitialized values */
}
@@ -54,12 +54,11 @@ void GaussianAlphaYBlurOperation::initExecution()
initMutex();
if (this->m_sizeavailable) {
- float rad = this->m_size * this->m_data->sizey;
- CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);
-
- this->m_rad = rad;
- this->m_gausstab = BlurBaseOperation::make_gausstab(rad);
- this->m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->m_falloff);
+ float rad = max_ff(m_size * m_data->sizey, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+
+ m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
+ m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
}
}
@@ -67,20 +66,18 @@ void GaussianAlphaYBlurOperation::updateGauss()
{
if (this->m_gausstab == NULL) {
updateSize();
- float rad = this->m_size * this->m_data->sizey;
- CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);
-
- this->m_rad = rad;
- this->m_gausstab = BlurBaseOperation::make_gausstab(rad);
+ float rad = max_ff(m_size * m_data->sizey, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+
+ m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
}
if (this->m_distbuf_inv == NULL) {
updateSize();
- float rad = this->m_size * this->m_data->sizex;
- CLAMP(rad, 1.0f, MAX_GAUSSTAB_RADIUS);
-
- this->m_rad = rad;
- this->m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->m_falloff);
+ float rad = max_ff(m_size * m_data->sizey, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+
+ m_distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, m_filtersize, m_falloff);
}
}
@@ -98,12 +95,10 @@ void GaussianAlphaYBlurOperation::executePixel(float output[4], int x, int y, vo
int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = inputBuffer->getRect()->ymin;
- int miny = y - this->m_rad;
- int maxy = y + this->m_rad;
- int minx = x;
- miny = max(miny, inputBuffer->getRect()->ymin);
- minx = max(minx, inputBuffer->getRect()->xmin);
- maxy = min(maxy, inputBuffer->getRect()->ymax - 1);
+ rcti &rect = *inputBuffer->getRect();
+ int xmin = max_ii(x, rect.xmin);
+ int ymin = max_ii(y - m_filtersize, rect.ymin);
+ int ymax = min_ii(y + m_filtersize + 1, rect.ymax);
/* *** this is the main part which is different to 'GaussianYBlurOperation' *** */
int step = getStep();
@@ -116,10 +111,10 @@ void GaussianAlphaYBlurOperation::executePixel(float output[4], int x, int y, vo
float value_max = finv_test(buffer[(x * 4) + (y * 4 * bufferwidth)], do_invert); /* init with the current color to avoid unneeded lookups */
float distfacinv_max = 1.0f; /* 0 to 1 */
- for (int ny = miny; ny <= maxy; ny += step) {
- int bufferindex = ((minx - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
+ for (int ny = ymin; ny < ymax; ny += step) {
+ int bufferindex = ((xmin - bufferstartx) * 4) + ((ny - bufferstarty) * 4 * bufferwidth);
- const int index = (ny - y) + this->m_rad;
+ const int index = (ny - y) + this->m_filtersize;
float value = finv_test(buffer[bufferindex], do_invert);
float multiplier;
@@ -179,8 +174,8 @@ bool GaussianAlphaYBlurOperation::determineDependingAreaOfInterest(rcti *input,
if (this->m_sizeavailable && this->m_gausstab != NULL) {
newInput.xmax = input->xmax;
newInput.xmin = input->xmin;
- newInput.ymax = input->ymax + this->m_rad + 1;
- newInput.ymin = input->ymin - this->m_rad - 1;
+ newInput.ymax = input->ymax + this->m_filtersize + 1;
+ newInput.ymin = input->ymin - this->m_filtersize - 1;
}
else {
newInput.xmax = this->getWidth();