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>2015-10-26 18:23:18 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2015-10-28 00:43:06 +0300
commitc07c066685658fc5a9f070ab9f9e8fb97926568a (patch)
treeef18d42087eb31dd175c780e015f4e1e3372e655 /intern/cycles/render
parent548ef2d88b941d5b20692a6eea997e37366fbe2b (diff)
Cycles: Use new CDF evaluation utility for the pixel filter
Filter table should stay exactly the same, no changes in the render results are expected at all.
Diffstat (limited to 'intern/cycles/render')
-rw-r--r--intern/cycles/render/film.cpp54
1 files changed, 19 insertions, 35 deletions
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index 58080289633..ce3f5b180ff 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -26,6 +26,7 @@
#include "util_debug.h"
#include "util_foreach.h"
#include "util_math.h"
+#include "util_math_cdf.h"
CCL_NAMESPACE_BEGIN
@@ -214,11 +215,8 @@ static float filter_func_gaussian(float v, float width)
static vector<float> filter_table(FilterType type, float width)
{
- const int filter_table_size = FILTER_TABLE_SIZE-1;
- vector<float> filter_table_cdf(filter_table_size+1);
- vector<float> filter_table(filter_table_size+1);
+ vector<float> filter_table(FILTER_TABLE_SIZE);
float (*filter_func)(float, float) = NULL;
- int i, half_size = filter_table_size/2;
switch(type) {
case FILTER_BOX:
@@ -231,37 +229,23 @@ static vector<float> filter_table(FilterType type, float width)
assert(0);
}
- /* compute cumulative distribution function */
- filter_table_cdf[0] = 0.0f;
-
- for(i = 0; i < filter_table_size; i++) {
- float x = i*width*0.5f/(filter_table_size-1);
- float y = filter_func(x, width);
- filter_table_cdf[i+1] += filter_table_cdf[i] + fabsf(y);
- }
-
- for(i = 0; i <= filter_table_size; i++)
- filter_table_cdf[i] /= filter_table_cdf[filter_table_size];
-
- /* create importance sampling table */
- for(i = 0; i <= half_size; i++) {
- float x = i/(float)half_size;
- int index = upper_bound(filter_table_cdf.begin(), filter_table_cdf.end(), x) - filter_table_cdf.begin();
- float t;
-
- if(index < filter_table_size+1) {
- t = (x - filter_table_cdf[index])/(filter_table_cdf[index+1] - filter_table_cdf[index]);
- }
- else {
- t = 0.0f;
- index = filter_table_size;
- }
-
- float y = ((index + t)/(filter_table_size))*width;
-
- filter_table[half_size+i] = 0.5f*(1.0f + y);
- filter_table[half_size-i] = 0.5f*(1.0f - y);
- }
+ /* Create importance sampling table. */
+
+ /* TODO(sergey): With the even filter table size resolution we can not
+ * really make it nice symmetric importance map without sampling full range
+ * (meaning, we would need to sample full filter range and not use the
+ * make_symmetric argument).
+ *
+ * Current code matches exactly initial filter table code, but we should
+ * consider either making FILTER_TABLE_SIZE odd value or sample full filter.
+ */
+
+ util_cdf_inverted(FILTER_TABLE_SIZE,
+ 0.0f,
+ width * 0.5f,
+ function_bind(filter_func, _1, width),
+ true,
+ filter_table);
return filter_table;
}