[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45694] branches/soc-2011-tomato/intern/ cycles: Cycles: add "Blur Glossy" integrator option.

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Apr 16 14:57:11 CEST 2012


Revision: 45694
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45694
Author:   blendix
Date:     2012-04-16 12:57:11 +0000 (Mon, 16 Apr 2012)
Log Message:
-----------
Cycles: add "Blur Glossy" integrator option.

When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak. 

Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.

Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting. 


(note that this is being committed to the tomato branch, mango will be using
this branch until feature freeze for 2.63 is over, then switch back)

Modified Paths:
--------------
    branches/soc-2011-tomato/intern/cycles/blender/addon/properties.py
    branches/soc-2011-tomato/intern/cycles/blender/addon/ui.py
    branches/soc-2011-tomato/intern/cycles/blender/blender_sync.cpp
    branches/soc-2011-tomato/intern/cycles/kernel/kernel_path.h
    branches/soc-2011-tomato/intern/cycles/kernel/kernel_types.h
    branches/soc-2011-tomato/intern/cycles/render/integrator.cpp
    branches/soc-2011-tomato/intern/cycles/render/integrator.h

Modified: branches/soc-2011-tomato/intern/cycles/blender/addon/properties.py
===================================================================
--- branches/soc-2011-tomato/intern/cycles/blender/addon/properties.py	2012-04-16 12:47:34 UTC (rev 45693)
+++ branches/soc-2011-tomato/intern/cycles/blender/addon/properties.py	2012-04-16 12:57:11 UTC (rev 45694)
@@ -85,10 +85,10 @@
                 description="Leave out caustics, resulting in a darker image with less noise",
                 default=False,
                 )
-        cls.blur_caustics = FloatProperty(
-                name="Blur Caustics",
-                description="Blur caustics to reduce noise",
-                min=0.0, max=1.0,
+        cls.blur_glossy = FloatProperty(
+                name="Blur Glossy",
+                description="Adaptively blur glossy shaders after blurry bounces, to reduce noise at the cost of accuracy",
+                min=0.0, max=10.0,
                 default=0.0,
                 )
 

Modified: branches/soc-2011-tomato/intern/cycles/blender/addon/ui.py
===================================================================
--- branches/soc-2011-tomato/intern/cycles/blender/addon/ui.py	2012-04-16 12:47:34 UTC (rev 45693)
+++ branches/soc-2011-tomato/intern/cycles/blender/addon/ui.py	2012-04-16 12:57:11 UTC (rev 45694)
@@ -87,13 +87,13 @@
         sub.prop(cscene, "diffuse_bounces", text="Diffuse")
         sub.prop(cscene, "glossy_bounces", text="Glossy")
         sub.prop(cscene, "transmission_bounces", text="Transmission")
-        sub.prop(cscene, "no_caustics")
 
-        #row = col.row()
-        #row.prop(cscene, "blur_caustics")
-        #row.active = not cscene.no_caustics
+        col.separator()
 
+        col.prop(cscene, "no_caustics")
+        col.prop(cscene, "blur_glossy")
 
+
 class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
     bl_label = "Film"
 

Modified: branches/soc-2011-tomato/intern/cycles/blender/blender_sync.cpp
===================================================================
--- branches/soc-2011-tomato/intern/cycles/blender/blender_sync.cpp	2012-04-16 12:47:34 UTC (rev 45693)
+++ branches/soc-2011-tomato/intern/cycles/blender/blender_sync.cpp	2012-04-16 12:57:11 UTC (rev 45694)
@@ -153,6 +153,8 @@
 	integrator->transparent_shadows = get_boolean(cscene, "use_transparent_shadows");
 
 	integrator->no_caustics = get_boolean(cscene, "no_caustics");
+	integrator->blur_glossy = get_float(cscene, "blur_glossy");
+
 	integrator->seed = get_int(cscene, "seed");
 
 	integrator->layer_flag = render_layer.layer;

Modified: branches/soc-2011-tomato/intern/cycles/kernel/kernel_path.h
===================================================================
--- branches/soc-2011-tomato/intern/cycles/kernel/kernel_path.h	2012-04-16 12:47:34 UTC (rev 45693)
+++ branches/soc-2011-tomato/intern/cycles/kernel/kernel_path.h	2012-04-16 12:57:11 UTC (rev 45694)
@@ -223,6 +223,7 @@
 
 	path_radiance_init(&L, kernel_data.film.use_light_pass);
 
+	float min_ray_pdf = FLT_MAX;
 	float ray_pdf = 0.0f;
 	PathState state;
 	int rng_offset = PRNG_BASE_NUM;
@@ -259,6 +260,18 @@
 
 		kernel_write_data_passes(kg, buffer, &L, &sd, sample, state.flag, throughput);
 
+		/* blurring of bsdf after bounces, for rays that have a small likelihood
+		   of following this particular path (diffuse, rough glossy) */
+		if(kernel_data.integrator.blur_glossy != FLT_MAX) {
+			float blur_pdf = kernel_data.integrator.blur_glossy*min_ray_pdf;
+
+			if(blur_pdf < 1.0f) {
+				float blur_roughness = sqrtf(1.0f - blur_pdf)*0.5f;
+				shader_bsdf_blur(kg, &sd, blur_roughness);
+			}
+		}
+
+		/* holdout */
 #ifdef __HOLDOUT__
 		if((sd.flag & SD_HOLDOUT) && (state.flag & PATH_RAY_CAMERA)) {
 			float3 holdout_weight = shader_holdout_eval(kg, &sd);
@@ -378,8 +391,10 @@
 		path_radiance_bsdf_bounce(&L, &throughput, &bsdf_eval, bsdf_pdf, state.bounce, label);
 
 		/* set labels */
-		if(!(label & LABEL_TRANSPARENT))
+		if(!(label & LABEL_TRANSPARENT)) {
 			ray_pdf = bsdf_pdf;
+			min_ray_pdf = fminf(bsdf_pdf, min_ray_pdf);
+		}
 
 		/* update path state */
 		path_state_next(kg, &state, label);

Modified: branches/soc-2011-tomato/intern/cycles/kernel/kernel_types.h
===================================================================
--- branches/soc-2011-tomato/intern/cycles/kernel/kernel_types.h	2012-04-16 12:47:34 UTC (rev 45693)
+++ branches/soc-2011-tomato/intern/cycles/kernel/kernel_types.h	2012-04-16 12:57:11 UTC (rev 45694)
@@ -516,6 +516,7 @@
 
 	/* caustics */
 	int no_caustics;
+	float blur_glossy;
 
 	/* seed */
 	int seed;
@@ -525,9 +526,6 @@
 
 	/* clamp */
 	float sample_clamp;
-
-	/* padding */
-	int pad;
 } KernelIntegrator;
 
 typedef struct KernelBVH {

Modified: branches/soc-2011-tomato/intern/cycles/render/integrator.cpp
===================================================================
--- branches/soc-2011-tomato/intern/cycles/render/integrator.cpp	2012-04-16 12:47:34 UTC (rev 45693)
+++ branches/soc-2011-tomato/intern/cycles/render/integrator.cpp	2012-04-16 12:57:11 UTC (rev 45694)
@@ -41,6 +41,7 @@
 	transparent_shadows = false;
 
 	no_caustics = false;
+	blur_glossy = 0.0f;
 	seed = 0;
 	layer_flag = ~0;
 	sample_clamp = 0.0f;
@@ -81,6 +82,8 @@
 	kintegrator->transparent_shadows = transparent_shadows;
 
 	kintegrator->no_caustics = no_caustics;
+	kintegrator->blur_glossy = (blur_glossy == 0.0f)? FLT_MAX: 1.0f/blur_glossy;
+
 	kintegrator->seed = hash_int(seed);
 	kintegrator->layer_flag = layer_flag << PATH_RAY_LAYER_SHIFT;
 
@@ -119,6 +122,7 @@
 		transparent_probalistic == integrator.transparent_probalistic &&
 		transparent_shadows == integrator.transparent_shadows &&
 		no_caustics == integrator.no_caustics &&
+		blur_glossy == integrator.blur_glossy &&
 		layer_flag == integrator.layer_flag &&
 		seed == integrator.seed &&
 		sample_clamp == integrator.sample_clamp);

Modified: branches/soc-2011-tomato/intern/cycles/render/integrator.h
===================================================================
--- branches/soc-2011-tomato/intern/cycles/render/integrator.h	2012-04-16 12:47:34 UTC (rev 45693)
+++ branches/soc-2011-tomato/intern/cycles/render/integrator.h	2012-04-16 12:57:11 UTC (rev 45694)
@@ -41,6 +41,7 @@
 	bool transparent_shadows;
 
 	bool no_caustics;
+	float blur_glossy;
 
 	int seed;
 	int layer_flag;




More information about the Bf-blender-cvs mailing list