[Bf-blender-cvs] [8dea065] master: Cycles: Add Blackman-Harris filter, fix Gaussian filter

Lukas Stockner noreply at git.blender.org
Wed Nov 18 20:52:50 CET 2015


Commit: 8dea06565f11f706195c89dcfcd7867b887a0ff7
Author: Lukas Stockner
Date:   Thu Aug 6 21:04:43 2015 +0200
Branches: master
https://developer.blender.org/rB8dea06565f11f706195c89dcfcd7867b887a0ff7

Cycles: Add Blackman-Harris filter, fix Gaussian filter

This commit adds the Blackman-Harris windows function as a pixel filter to Cycles. On some cases, such as wireframes or high-frequency textures,
Blackman-Harris can give subtle but noticable improvements over the Gaussian window.
Also, the gaussian window was truncated too early, which degraded quality a bit, therefore the evaluation region is now three times as wide.
To avoid artifacts caused by the wider curve, the filter table size is increased to 1024.

Reviewers: #cycles

Differential Revision: https://developer.blender.org/D1453

===================================================================

M	intern/cycles/blender/addon/properties.py
M	intern/cycles/kernel/kernel_types.h
M	intern/cycles/render/film.cpp
M	intern/cycles/render/film.h

===================================================================

diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index c313983..cbd1a8b 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -54,6 +54,7 @@ enum_bvh_types = (
 enum_filter_types = (
     ('BOX', "Box", "Box filter"),
     ('GAUSSIAN', "Gaussian", "Gaussian filter"),
+    ('BLACKMAN_HARRIS', "Blackman-Harris", "Blackman-Harris filter"),
     )
 
 enum_aperture_types = (
diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h
index 1d71e64..75a9e21 100644
--- a/intern/cycles/kernel/kernel_types.h
+++ b/intern/cycles/kernel/kernel_types.h
@@ -37,7 +37,7 @@ CCL_NAMESPACE_BEGIN
 #define OBJECT_SIZE 		11
 #define OBJECT_VECTOR_SIZE	6
 #define LIGHT_SIZE			5
-#define FILTER_TABLE_SIZE	256
+#define FILTER_TABLE_SIZE	1024
 #define RAMP_TABLE_SIZE		256
 #define SHUTTER_TABLE_SIZE		256
 #define PARTICLE_SIZE 		5
diff --git a/intern/cycles/render/film.cpp b/intern/cycles/render/film.cpp
index ce3f5b1..abdd1c2 100644
--- a/intern/cycles/render/film.cpp
+++ b/intern/cycles/render/film.cpp
@@ -209,10 +209,16 @@ static float filter_func_box(float /*v*/, float /*width*/)
 
 static float filter_func_gaussian(float v, float width)
 {
-	v *= 2.0f/width;
+	v *= 6.0f/width;
 	return expf(-2.0f*v*v);
 }
 
+static float filter_func_blackman_harris(float v, float width)
+{
+	v = M_2PI_F * (v / width + 0.5f);
+	return 0.35875f - 0.48829f*cosf(v) + 0.14128f*cosf(2.0f*v) - 0.01168f*cosf(3.0f*v);
+}
+
 static vector<float> filter_table(FilterType type, float width)
 {
 	vector<float> filter_table(FILTER_TABLE_SIZE);
@@ -224,6 +230,11 @@ static vector<float> filter_table(FilterType type, float width)
 			break;
 		case FILTER_GAUSSIAN:
 			filter_func = filter_func_gaussian;
+			width *= 3.0f;
+			break;
+		case FILTER_BLACKMAN_HARRIS:
+			filter_func = filter_func_blackman_harris;
+			width *= 2.0f;
 			break;
 		default:
 			assert(0);
diff --git a/intern/cycles/render/film.h b/intern/cycles/render/film.h
index e2cd63c..0fde928 100644
--- a/intern/cycles/render/film.h
+++ b/intern/cycles/render/film.h
@@ -30,7 +30,8 @@ class Scene;
 
 typedef enum FilterType {
 	FILTER_BOX,
-	FILTER_GAUSSIAN
+	FILTER_GAUSSIAN,
+	FILTER_BLACKMAN_HARRIS
 } FilterType;
 
 class Pass {




More information about the Bf-blender-cvs mailing list