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_BlurBaseOperation.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_BlurBaseOperation.cpp')
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
index c8d53b6992d..d13fea921be 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
@@ -68,20 +68,21 @@ void BlurBaseOperation::initExecution()
}
-float *BlurBaseOperation::make_gausstab(int rad)
+float *BlurBaseOperation::make_gausstab(float rad, int size)
{
float *gausstab, sum, val;
int i, n;
- n = 2 * rad + 1;
+ n = 2 * size + 1;
gausstab = (float *)MEM_mallocN(sizeof(float) * n, __func__);
sum = 0.0f;
- for (i = -rad; i <= rad; i++) {
- val = RE_filter_value(this->m_data->filtertype, (float)i / (float)rad);
+ float fac = (rad > 0.0f ? 1.0f/rad : 0.0f);
+ for (i = -size; i <= size; i++) {
+ val = RE_filter_value(this->m_data->filtertype, (float)i * fac);
sum += val;
- gausstab[i + rad] = val;
+ gausstab[i + size] = val;
}
sum = 1.0f / sum;
@@ -93,17 +94,18 @@ float *BlurBaseOperation::make_gausstab(int rad)
/* normalized distance from the current (inverted so 1.0 is close and 0.0 is far)
* 'ease' is applied after, looks nicer */
-float *BlurBaseOperation::make_dist_fac_inverse(int rad, int falloff)
+float *BlurBaseOperation::make_dist_fac_inverse(float rad, int size, int falloff)
{
float *dist_fac_invert, val;
int i, n;
- n = 2 * rad + 1;
+ n = 2 * size + 1;
dist_fac_invert = (float *)MEM_mallocN(sizeof(float) * n, __func__);
- for (i = -rad; i <= rad; i++) {
- val = 1.0f - fabsf(((float)i / (float)rad));
+ float fac = (rad > 0.0f ? 1.0f/rad : 0.0f);
+ for (i = -size; i <= size; i++) {
+ val = 1.0f - fabsf((float)i * fac);
/* keep in sync with proportional_falloff_curve_only_items */
switch (falloff) {
@@ -132,7 +134,7 @@ float *BlurBaseOperation::make_dist_fac_inverse(int rad, int falloff)
/* nothing */
break;
}
- dist_fac_invert[i + rad] = val;
+ dist_fac_invert[i + size] = val;
}
return dist_fac_invert;