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_GaussianXBlurOperation.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_GaussianXBlurOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp38
1 files changed, 17 insertions, 21 deletions
diff --git a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
index 648ca0965c8..127417bf701 100644
--- a/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianXBlurOperation.cpp
@@ -31,7 +31,7 @@ extern "C" {
GaussianXBlurOperation::GaussianXBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{
this->m_gausstab = NULL;
- this->m_rad = 0;
+ this->m_filtersize = 0;
}
void *GaussianXBlurOperation::initializeTileData(rcti *rect)
@@ -52,11 +52,10 @@ void GaussianXBlurOperation::initExecution()
initMutex();
if (this->m_sizeavailable) {
- float rad = this->m_size * this->m_data->sizex;
- 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->sizex, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+
+ this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
}
}
@@ -64,11 +63,10 @@ void GaussianXBlurOperation::updateGauss()
{
if (this->m_gausstab == NULL) {
updateSize();
- float rad = this->m_size * this->m_data->sizex;
- 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->sizex, 0.0f);
+ m_filtersize = min_ii(ceil(rad), MAX_GAUSSTAB_RADIUS);
+
+ this->m_gausstab = BlurBaseOperation::make_gausstab(rad, m_filtersize);
}
}
@@ -82,17 +80,15 @@ void GaussianXBlurOperation::executePixel(float output[4], int x, int y, void *d
int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = inputBuffer->getRect()->ymin;
- int miny = y;
- int minx = x - this->m_rad;
- int maxx = x + this->m_rad;
- miny = max(miny, inputBuffer->getRect()->ymin);
- minx = max(minx, inputBuffer->getRect()->xmin);
- maxx = min(maxx, inputBuffer->getRect()->xmax - 1);
+ rcti &rect = *inputBuffer->getRect();
+ int xmin = max_ii(x - m_filtersize, rect.xmin);
+ int xmax = min_ii(x + m_filtersize + 1, rect.xmax);
+ int ymin = max_ii(y, rect.ymin);
int step = getStep();
int offsetadd = getOffsetAdd();
- int bufferindex = ((minx - bufferstartx) * 4) + ((miny - bufferstarty) * 4 * bufferwidth);
- for (int nx = minx, index = (minx - x) + this->m_rad; nx <= maxx; nx += step, index += step) {
+ int bufferindex = ((xmin - bufferstartx) * 4) + ((ymin - bufferstarty) * 4 * bufferwidth);
+ for (int nx = xmin, index = (xmin - x) + this->m_filtersize; nx < xmax; nx += step, index += step) {
const float multiplier = this->m_gausstab[index];
madd_v4_v4fl(color_accum, &buffer[bufferindex], multiplier);
multiplier_accum += multiplier;
@@ -129,8 +125,8 @@ bool GaussianXBlurOperation::determineDependingAreaOfInterest(rcti *input, ReadB
}
{
if (this->m_sizeavailable && this->m_gausstab != NULL) {
- newInput.xmax = input->xmax + this->m_rad + 1;
- newInput.xmin = input->xmin - this->m_rad - 1;
+ newInput.xmax = input->xmax + this->m_filtersize + 1;
+ newInput.xmin = input->xmin - this->m_filtersize - 1;
newInput.ymax = input->ymax;
newInput.ymin = input->ymin;
}