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:
authorSergey Sharybin <sergey.vfx@gmail.com>2014-10-31 14:15:38 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2014-10-31 14:19:12 +0300
commitfcc2ca008907a897286d1dfcd9c9105677f71ea8 (patch)
treedfa55c2b15e3952e5105e64cf15e9f517f4f6cac
parentb154aa8c060a60d476970bb8b8fab3912a2afc22 (diff)
Fix T42401: Gaussian blur node is visibly squared-off at larger sizes
The root of the issue comes to the way how we sample the gaussian filter in RE_filter_value(). We need to scale x to -3*sigma..3*sigma segment in order to get the whole bell. The old code tried to do it, but failed dramatically, plus it used some weird gaussian sampling formula. Replaced it with much more clear one, which gives proper blur now. There's no visible different in AA sampling in BI render tho. Other filters like Mitchell still tends to give wrong square shaped blurs, but they're much more difficult to resolve because they're just wrong in the code -- for some reason smaller kernel size means more blur. Let's solve this later.
-rw-r--r--source/blender/render/intern/source/initrender.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 353ba5d5caa..4bb5dc154a6 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -164,8 +164,11 @@ float RE_filter_value(int type, float x)
return 1.0f - x;
case R_FILTER_GAUSS:
- x *= gaussfac;
- return (1.0f / expf(x * x) - 1.0f / expf(gaussfac * gaussfac * 2.25f));
+ {
+ const float two_gaussfac2 = 2.0f * gaussfac * gaussfac;
+ x *= 3.0f * gaussfac;
+ return 1.0f / sqrtf(M_PI * two_gaussfac2) * expf(-x*x / two_gaussfac2);
+ }
case R_FILTER_MITCH:
return filt_mitchell(x * gaussfac);