[Bf-blender-cvs] [d0724d8] cycles_panorama_experiments: Cycles: Commit hack which allows to render less samples on the poles

Sergey Sharybin noreply at git.blender.org
Thu Mar 31 11:47:52 CEST 2016


Commit: d0724d897aeedfa9047666ec7f6271910ff4e7c2
Author: Sergey Sharybin
Date:   Thu Mar 31 11:44:46 2016 +0200
Branches: cycles_panorama_experiments
https://developer.blender.org/rBd0724d897aeedfa9047666ec7f6271910ff4e7c2

Cycles: Commit hack which allows to render less samples on the poles

This is more an experiment for now to see how it could improve render
times without loosing too much quality. Implementation is quite hacky
due to timing constraints here.

Now it is possible to control how much samples will be rendered on
the pole, so now regular Samples are controlling samples in the middle
of the frame, and those samples are falling off to the pole samples
using sine interpolation.

Limitations:

- Only works for final renders without progressive refine option.
- It is per-tile samples, so tile size should be small enough to
  see an effect.

This is not something even nearly considered for master, more like
a research and test project.

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

M	intern/cycles/blender/addon/properties.py
M	intern/cycles/blender/addon/ui.py
M	intern/cycles/blender/blender_sync.cpp
M	intern/cycles/render/session.cpp
M	intern/cycles/render/session.h

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

diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index 3a83e2c..b104f19 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -169,6 +169,12 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
                 min=1, max=2147483647,
                 default=128,
                 )
+        cls.pole_samples = IntProperty(
+                name="Pole Samples",
+                description="Number of samples to fade to on the poles when rendering equirectangular panorama (0 disables fade)",
+                min=0, max=2147483647,
+                default=0,
+                )
         cls.preview_samples = IntProperty(
                 name="Preview Samples",
                 description="Number of samples to render in the viewport, unlimited if 0",
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index b9e51df..ac57566 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -174,10 +174,12 @@ class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel):
             sub.label(text="Samples:")
             sub.prop(cscene, "samples", text="Render")
             sub.prop(cscene, "preview_samples", text="Preview")
+            sub.prop(cscene, "pole_samples", text="Pole")
         else:
             sub.label(text="AA Samples:")
             sub.prop(cscene, "aa_samples", text="Render")
             sub.prop(cscene, "preview_aa_samples", text="Preview")
+            sub.prop(cscene, "pole_samples", text="Pole")
             sub.separator()
             sub.prop(cscene, "sample_all_lights_direct")
             sub.prop(cscene, "sample_all_lights_indirect")
diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp
index 749b8c0..9131325 100644
--- a/intern/cycles/blender/blender_sync.cpp
+++ b/intern/cycles/blender/blender_sync.cpp
@@ -536,6 +536,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
 	/* samples */
 	int samples = get_int(cscene, "samples");
 	int aa_samples = get_int(cscene, "aa_samples");
+	int pole_samples = get_int(cscene, "pole_samples");
 	int preview_samples = get_int(cscene, "preview_samples");
 	int preview_aa_samples = get_int(cscene, "preview_aa_samples");
 	
@@ -545,6 +546,7 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
 
 		samples = samples * samples;
 		preview_samples = preview_samples * preview_samples;
+		pole_samples = pole_samples * pole_samples;
 	}
 
 	if(get_enum(cscene, "progressive") == 0) {
@@ -568,6 +570,8 @@ SessionParams BlenderSync::get_session_params(BL::RenderEngine& b_engine,
 		}
 	}
 
+	params.pole_samples = pole_samples;
+
 	/* tiles */
 	if(params.device.type != DEVICE_CPU && !background) {
 		/* currently GPU could be much slower than CPU when using tiles,
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index 84a420c..f78c28b 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -368,7 +368,7 @@ bool Session::acquire_tile(Device *tile_device, RenderTile& rtile)
 
 	if(!tile_manager.next_tile(tile, device_num))
 		return false;
-	
+
 	/* fill render tile */
 	rtile.x = tile_manager.state.buffer.full_x + tile.x;
 	rtile.y = tile_manager.state.buffer.full_y + tile.y;
@@ -378,6 +378,26 @@ bool Session::acquire_tile(Device *tile_device, RenderTile& rtile)
 	rtile.num_samples = tile_manager.state.num_samples;
 	rtile.resolution = tile_manager.state.resolution_divider;
 
+	if(params.background &&
+	   !params.progressive_refine &&
+	   scene->camera->type == CAMERA_PANORAMA &&
+	   scene->camera->panorama_type == PANORAMA_EQUIRECTANGULAR &&
+	   params.pole_samples != 0)
+	{
+		const int tot_samples = params.samples;
+		const int min_samples = params.pole_samples;
+		const int full_height = tile_manager.state.buffer.full_height;
+		const int2 tile_size = params.tile_size;
+		int aligned_height = (int)ceilf((float)full_height / tile_size.y) * tile_size.y;
+		float v = (float)rtile.y / (aligned_height - tile_size.y);
+		float fac = sinf(v * M_PI_F);
+		fac = clamp(fac, 0.0f, 1.0f);
+		rtile.num_samples = min_samples + (int)((tot_samples - min_samples) * fac);
+		VLOG(1) << "Using panorama tile sampling hack for tile at ("
+		        << rtile.x << "), " << rtile.y << ", "
+		        << "samples " << rtile.num_samples;
+	}
+
 	tile_lock.unlock();
 
 	/* in case of a permanent buffer, return it, otherwise we will allocate
diff --git a/intern/cycles/render/session.h b/intern/cycles/render/session.h
index c669bcc..cb5a32a 100644
--- a/intern/cycles/render/session.h
+++ b/intern/cycles/render/session.h
@@ -50,6 +50,7 @@ public:
 	bool progressive;
 	bool experimental;
 	int samples;
+	int pole_samples;
 	int2 tile_size;
 	TileOrder tile_order;
 	int start_resolution;
@@ -73,6 +74,7 @@ public:
 		progressive = false;
 		experimental = false;
 		samples = USHRT_MAX;
+		pole_samples = 0;
 		tile_size = make_int2(64, 64);
 		start_resolution = INT_MAX;
 		threads = 0;
@@ -95,6 +97,7 @@ public:
 		&& progressive_refine == params.progressive_refine
 		&& output_path == params.output_path
 		/* && samples == params.samples */
+		&& pole_samples == params.pole_samples
 		&& progressive == params.progressive
 		&& experimental == params.experimental
 		&& tile_size == params.tile_size




More information about the Bf-blender-cvs mailing list