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:
authorCampbell Barton <ideasman42@gmail.com>2012-06-21 11:45:41 +0400
committerCampbell Barton <ideasman42@gmail.com>2012-06-21 11:45:41 +0400
commitfae0b2068b2287fdce76116ff5e0503040f5be61 (patch)
tree9e232485fe84e8261402ef26fa5ee66c23c78140 /source/blender/compositor/operations
parent19e81b12e774d800cff8e5de7b450f65d108a451 (diff)
falloff options for dilate/erode feather compo node.
Diffstat (limited to 'source/blender/compositor/operations')
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.cpp25
-rw-r--r--source/blender/compositor/operations/COM_BlurBaseOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h2
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp4
-rw-r--r--source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h2
6 files changed, 30 insertions, 9 deletions
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
index a233c7a50ae..df64b7c8ddc 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.cpp
@@ -91,7 +91,7 @@ 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)
+float *BlurBaseOperation::make_dist_fac_inverse(int rad, int falloff)
{
float *dist_fac_invert, val;
int i, n;
@@ -103,9 +103,26 @@ float *BlurBaseOperation::make_dist_fac_inverse(int rad)
for (i = -rad; i <= rad; i++) {
val = 1.0f - fabsf(((float)i / (float)rad));
- /* ease - gives less hard lines for dilate/erode feather */
- val = (3.0f * val * val - 2.0f * val * val * val);
-
+ /* keep in sync with proportional_falloff_curve_only_items */
+ switch (falloff) {
+ case PROP_SMOOTH:
+ /* ease - gives less hard lines for dilate/erode feather */
+ val = (3.0f * val * val - 2.0f * val * val * val);
+ break;
+ case PROP_SPHERE:
+ val = sqrtf(2.0f * val - val * val);
+ break;
+ case PROP_ROOT:
+ val = sqrtf(val);
+ break;
+ case PROP_SHARP:
+ val = val * val;
+ break;
+ case PROP_LIN:
+ default:
+ /* nothing */
+ break;
+ }
dist_fac_invert[i + rad] = val;
}
diff --git a/source/blender/compositor/operations/COM_BlurBaseOperation.h b/source/blender/compositor/operations/COM_BlurBaseOperation.h
index 33c07abbb36..8f7208274db 100644
--- a/source/blender/compositor/operations/COM_BlurBaseOperation.h
+++ b/source/blender/compositor/operations/COM_BlurBaseOperation.h
@@ -37,7 +37,7 @@ protected:
NodeBlurData *data;
BlurBaseOperation(DataType data_type);
float *make_gausstab(int rad);
- float *make_dist_fac_inverse(int rad);
+ float *make_dist_fac_inverse(int rad, int falloff);
float size;
bool deleteData;
bool sizeavailable;
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
index 1283ac48923..954aef7b916 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.cpp
@@ -54,7 +54,7 @@ void GaussianAlphaXBlurOperation::initExecution()
this->rad = rad;
this->gausstab = BlurBaseOperation::make_gausstab(rad);
- this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad);
+ this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff);
}
}
@@ -77,7 +77,7 @@ void GaussianAlphaXBlurOperation::updateGauss(MemoryBuffer **memoryBuffers)
rad = 1;
this->rad = rad;
- this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad);
+ this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff);
}
}
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h
index 3268e51be01..38817ebef1d 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianAlphaXBlurOperation.h
@@ -30,6 +30,7 @@ class GaussianAlphaXBlurOperation : public BlurBaseOperation {
private:
float *gausstab;
float *distbuf_inv;
+ int falloff; /* falloff for distbuf_inv */
bool do_subtract;
int rad;
void updateGauss(MemoryBuffer **memoryBuffers);
@@ -58,5 +59,6 @@ public:
* Set subtract for Dilate/Erode functionality
*/
void setSubtract(bool subtract) { this->do_subtract = subtract; }
+ void setFalloff(int falloff) { this->falloff = falloff; }
};
#endif
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
index 1d67c23e41b..e1105cf94b1 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
+++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.cpp
@@ -54,7 +54,7 @@ void GaussianAlphaYBlurOperation::initExecution()
this->rad = rad;
this->gausstab = BlurBaseOperation::make_gausstab(rad);
- this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad);
+ this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff);
}
}
@@ -77,7 +77,7 @@ void GaussianAlphaYBlurOperation::updateGauss(MemoryBuffer **memoryBuffers)
rad = 1;
this->rad = rad;
- this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad);
+ this->distbuf_inv = BlurBaseOperation::make_dist_fac_inverse(rad, this->falloff);
}
}
diff --git a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h
index 0ffc264ba98..67166be8241 100644
--- a/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h
+++ b/source/blender/compositor/operations/COM_GaussianAlphaYBlurOperation.h
@@ -31,6 +31,7 @@ private:
float *gausstab;
float *distbuf_inv;
bool do_subtract;
+ int falloff;
int rad;
void updateGauss(MemoryBuffer **memoryBuffers);
public:
@@ -58,5 +59,6 @@ public:
* Set subtract for Dilate/Erode functionality
*/
void setSubtract(bool subtract) { this->do_subtract = subtract; }
+ void setFalloff(int falloff) { this->falloff = falloff; }
};
#endif