[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46023] trunk/blender: Cycles: merging features from tomato branch.

Brecht Van Lommel brechtvanlommel at pandora.be
Sat Apr 28 10:54:00 CEST 2012


Revision: 46023
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46023
Author:   blendix
Date:     2012-04-28 08:53:59 +0000 (Sat, 28 Apr 2012)
Log Message:
-----------
Cycles: merging features from tomato branch.

=== BVH build time optimizations ===

* BVH building was multithreaded. Not all building is multithreaded, packing
  and the initial bounding/splitting is still single threaded, but recursive
  splitting is, which was the main bottleneck.

* Object splitting now uses binning rather than sorting of all elements, using
  code from the Embree raytracer from Intel.
  http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/

* Other small changes to avoid allocations, pack memory more tightly, avoid
  some unnecessary operations, ...

These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.

BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.

=== Threads ===

Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.

Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.

=== Normal ====

Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.

In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.

=== Render Layers ===

Per render layer Samples control, leaving it to 0 will use the common scene
setting.

Environment pass will now render environment even if film is set to transparent.

Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.

=== Filter Glossy ===

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.

Modified Paths:
--------------
    trunk/blender/intern/cycles/blender/addon/properties.py
    trunk/blender/intern/cycles/blender/addon/ui.py
    trunk/blender/intern/cycles/blender/blender_session.cpp
    trunk/blender/intern/cycles/blender/blender_sync.cpp
    trunk/blender/intern/cycles/blender/blender_sync.h
    trunk/blender/intern/cycles/bvh/CMakeLists.txt
    trunk/blender/intern/cycles/bvh/bvh.cpp
    trunk/blender/intern/cycles/bvh/bvh_build.cpp
    trunk/blender/intern/cycles/bvh/bvh_build.h
    trunk/blender/intern/cycles/bvh/bvh_node.cpp
    trunk/blender/intern/cycles/bvh/bvh_node.h
    trunk/blender/intern/cycles/bvh/bvh_params.h
    trunk/blender/intern/cycles/bvh/bvh_sort.cpp
    trunk/blender/intern/cycles/bvh/bvh_sort.h
    trunk/blender/intern/cycles/device/device.cpp
    trunk/blender/intern/cycles/device/device.h
    trunk/blender/intern/cycles/device/device_cpu.cpp
    trunk/blender/intern/cycles/device/device_multi.cpp
    trunk/blender/intern/cycles/kernel/kernel_accumulate.h
    trunk/blender/intern/cycles/kernel/kernel_path.h
    trunk/blender/intern/cycles/kernel/kernel_types.h
    trunk/blender/intern/cycles/kernel/svm/svm_tex_coord.h
    trunk/blender/intern/cycles/kernel/svm/svm_types.h
    trunk/blender/intern/cycles/render/integrator.cpp
    trunk/blender/intern/cycles/render/integrator.h
    trunk/blender/intern/cycles/render/mesh.cpp
    trunk/blender/intern/cycles/render/nodes.cpp
    trunk/blender/intern/cycles/render/object.cpp
    trunk/blender/intern/cycles/render/session.cpp
    trunk/blender/intern/cycles/subd/subd_patch.cpp
    trunk/blender/intern/cycles/util/CMakeLists.txt
    trunk/blender/intern/cycles/util/util_boundbox.h
    trunk/blender/intern/cycles/util/util_math.h
    trunk/blender/intern/cycles/util/util_thread.h
    trunk/blender/intern/cycles/util/util_transform.cpp
    trunk/blender/intern/cycles/util/util_types.h
    trunk/blender/source/blender/gpu/intern/gpu_shader_material.glsl
    trunk/blender/source/blender/gpu/intern/gpu_shader_material.glsl.c
    trunk/blender/source/blender/makesdna/DNA_scene_types.h
    trunk/blender/source/blender/makesrna/intern/rna_scene.c
    trunk/blender/source/blender/render/extern/include/RE_pipeline.h
    trunk/blender/source/blender/render/intern/source/render_result.c

Added Paths:
-----------
    trunk/blender/intern/cycles/bvh/bvh_binning.cpp
    trunk/blender/intern/cycles/bvh/bvh_binning.h
    trunk/blender/intern/cycles/bvh/bvh_split.cpp
    trunk/blender/intern/cycles/bvh/bvh_split.h
    trunk/blender/intern/cycles/util/util_task.cpp
    trunk/blender/intern/cycles/util/util_task.h

Modified: trunk/blender/intern/cycles/blender/addon/properties.py
===================================================================
--- trunk/blender/intern/cycles/blender/addon/properties.py	2012-04-28 08:47:37 UTC (rev 46022)
+++ trunk/blender/intern/cycles/blender/addon/properties.py	2012-04-28 08:53:59 UTC (rev 46023)
@@ -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="Filter 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: trunk/blender/intern/cycles/blender/addon/ui.py
===================================================================
--- trunk/blender/intern/cycles/blender/addon/ui.py	2012-04-28 08:47:37 UTC (rev 46022)
+++ trunk/blender/intern/cycles/blender/addon/ui.py	2012-04-28 08:53:59 UTC (rev 46023)
@@ -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"
 
@@ -178,11 +178,8 @@
 
         col = split.column()
         col.prop(scene, "layers", text="Scene")
-        col.label(text="Material:")
-        col.prop(rl, "material_override", text="")
+        col.prop(rl, "layers_exclude", text="Exclude")
 
-        col.prop(rl, "use_sky", "Use Environment")
-
         col = split.column()
         col.prop(rl, "layers", text="Layer")
         col.label(text="Mask Layers:")
@@ -191,6 +188,16 @@
         split = layout.split()
 
         col = split.column()
+        col.label(text="Material:")
+        col.prop(rl, "material_override", text="")
+
+        col = split.column()
+        col.prop(rl, "samples")
+        col.prop(rl, "use_sky", "Use Environment")
+
+        split = layout.split()
+
+        col = split.column()
         col.label(text="Passes:")
         col.prop(rl, "use_pass_combined")
         col.prop(rl, "use_pass_z")

Modified: trunk/blender/intern/cycles/blender/blender_session.cpp
===================================================================
--- trunk/blender/intern/cycles/blender/blender_session.cpp	2012-04-28 08:47:37 UTC (rev 46022)
+++ trunk/blender/intern/cycles/blender/blender_session.cpp	2012-04-28 08:53:59 UTC (rev 46023)
@@ -218,12 +218,13 @@
 		scene->film->passes = passes;
 		scene->film->tag_update(scene);
 
-		/* update session */
-		session->reset(buffer_params, session_params.samples);
-
 		/* update scene */
 		sync->sync_data(b_v3d, b_iter->name().c_str());
 
+		/* update session */
+		int samples = sync->get_layer_samples();
+		session->reset(buffer_params, (samples == 0)? session_params.samples: samples);
+
 		/* render */
 		session->start();
 		session->wait();

Modified: trunk/blender/intern/cycles/blender/blender_sync.cpp
===================================================================
--- trunk/blender/intern/cycles/blender/blender_sync.cpp	2012-04-28 08:47:37 UTC (rev 46022)
+++ trunk/blender/intern/cycles/blender/blender_sync.cpp	2012-04-28 08:53:59 UTC (rev 46023)
@@ -153,6 +153,8 @@
 	integrator->transparent_shadows = get_boolean(cscene, "use_transparent_shadows");
 
 	integrator->no_caustics = get_boolean(cscene, "no_caustics");
+	integrator->filter_glossy = get_float(cscene, "blur_glossy");
+
 	integrator->seed = get_int(cscene, "seed");
 
 	integrator->layer_flag = render_layer.layer;
@@ -208,6 +210,7 @@
 			render_layer.holdout_layer = 0;
 			render_layer.material_override = PointerRNA_NULL;
 			render_layer.use_background = true;
+			render_layer.samples = 0;
 			return;
 		}
 	}
@@ -220,12 +223,13 @@
 	for(r.layers.begin(b_rlay); b_rlay != r.layers.end(); ++b_rlay) {
 		if((!layer && first_layer) || (layer && b_rlay->name() == layer)) {
 			render_layer.name = b_rlay->name();
-			render_layer.scene_layer = get_layer(b_scene.layers());
+			render_layer.scene_layer = get_layer(b_scene.layers()) & ~get_layer(b_rlay->layers_exclude());
 			render_layer.layer = get_layer(b_rlay->layers());
 			render_layer.holdout_layer = get_layer(b_rlay->layers_zmask());
 			render_layer.layer |= render_layer.holdout_layer;
 			render_layer.material_override = b_rlay->material_override();
 			render_layer.use_background = b_rlay->use_sky();
+			render_layer.samples = b_rlay->samples();
 		}
 
 		first_layer = false;

Modified: trunk/blender/intern/cycles/blender/blender_sync.h
===================================================================
--- trunk/blender/intern/cycles/blender/blender_sync.h	2012-04-28 08:47:37 UTC (rev 46022)
+++ trunk/blender/intern/cycles/blender/blender_sync.h	2012-04-28 08:53:59 UTC (rev 46023)
@@ -57,6 +57,7 @@
 	void sync_data(BL::SpaceView3D b_v3d, const char *layer = 0);
 	void sync_camera(BL::Object b_override, int width, int height);
 	void sync_view(BL::SpaceView3D b_v3d, BL::RegionView3D b_rv3d, int width, int height);
+	int get_layer_samples() { return render_layer.samples; }
 
 	/* get parameters */
 	static SceneParams get_scene_params(BL::Scene b_scene, bool background);
@@ -108,7 +109,8 @@
 		RenderLayerInfo()
 		: scene_layer(0), layer(0), holdout_layer(0),
 		  material_override(PointerRNA_NULL),
-		  use_background(true)
+		  use_background(true),
+		  samples(0)
 		{}
 
 		string name;
@@ -117,6 +119,7 @@
 		uint holdout_layer;
 		BL::Material material_override;
 		bool use_background;
+		int samples;
 	} render_layer;
 };
 

Modified: trunk/blender/intern/cycles/bvh/CMakeLists.txt
===================================================================
--- trunk/blender/intern/cycles/bvh/CMakeLists.txt	2012-04-28 08:47:37 UTC (rev 46022)
+++ trunk/blender/intern/cycles/bvh/CMakeLists.txt	2012-04-28 08:53:59 UTC (rev 46023)
@@ -10,17 +10,21 @@
 
 set(SRC
 	bvh.cpp
+	bvh_binning.cpp
 	bvh_build.cpp
 	bvh_node.cpp
 	bvh_sort.cpp
+	bvh_split.cpp
 )
 
 set(SRC_HEADERS
 	bvh.h
+	bvh_binning.h
 	bvh_build.h
 	bvh_node.h
 	bvh_params.h
 	bvh_sort.h
+	bvh_split.h
 )
 
 include_directories(${INC})

Modified: trunk/blender/intern/cycles/bvh/bvh.cpp
===================================================================
--- trunk/blender/intern/cycles/bvh/bvh.cpp	2012-04-28 08:47:37 UTC (rev 46022)
+++ trunk/blender/intern/cycles/bvh/bvh.cpp	2012-04-28 08:53:59 UTC (rev 46023)
@@ -530,7 +530,7 @@
 {
 	assert(!params.top_level);
 
-	BoundBox bbox;
+	BoundBox bbox = BoundBox::empty;
 	uint visibility = 0;
 	refit_node(0, (pack.is_leaf[0])? true: false, bbox, visibility);
 }
@@ -572,7 +572,7 @@
 	}
 	else {
 		/* refit inner node, set bbox from children */
-		BoundBox bbox0, bbox1;
+		BoundBox bbox0 = BoundBox::empty, bbox1 = BoundBox::empty;
 		uint visibility0 = 0, visibility1 = 0;
 
 		refit_node((c0 < 0)? -c0-1: c0, (c0 < 0), bbox0, visibility0);

Added: trunk/blender/intern/cycles/bvh/bvh_binning.cpp
===================================================================
--- trunk/blender/intern/cycles/bvh/bvh_binning.cpp	                        (rev 0)
+++ trunk/blender/intern/cycles/bvh/bvh_binning.cpp	2012-04-28 08:53:59 UTC (rev 46023)
@@ -0,0 +1,223 @@
+/*
+ * Adapted from code copyright 2009-2011 Intel Corporation
+ * Modifications Copyright 2012, Blender Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define __KERNEL_SSE__
+
+#include <stdlib.h>
+
+#include "bvh_binning.h"
+
+#include "util_algorithm.h"
+#include "util_boundbox.h"
+#include "util_types.h"
+
+CCL_NAMESPACE_BEGIN
+
+/* SSE replacements */
+
+__forceinline void prefetch_L1 (const void* ptr) { }
+__forceinline void prefetch_L2 (const void* ptr) { }
+__forceinline void prefetch_L3 (const void* ptr) { }
+__forceinline void prefetch_NTA(const void* ptr) { }
+
+template<size_t src> __forceinline float extract(const int4& b)
+{ return b[src]; }
+template<size_t dst> __forceinline const float4 insert(const float4& a, const float b)
+{ float4 r = a; r[dst] = b; return r; }
+
+__forceinline int get_best_dimension(const float4& bestSAH)
+{
+	// return (int)__bsf(movemask(reduce_min(bestSAH) == bestSAH));
+
+	float minSAH = min(bestSAH.x, min(bestSAH.y, bestSAH.z));
+
+	if(bestSAH.x == minSAH) return 0;
+	else if(bestSAH.y == minSAH) return 1;
+	else return 2;
+}
+
+/* BVH Object Binning */
+
+BVHObjectBinning::BVHObjectBinning(const BVHRange& job, BVHReference *prims)
+: BVHRange(job), splitSAH(FLT_MAX), dim(0), pos(0)
+{
+	/* compute number of bins to use and precompute scaling factor for binning */
+	num_bins = min(size_t(MAX_BINS), size_t(4.0f + 0.05f*size()));
+	scale = rcp(cent_bounds().size()) * make_float3((float)num_bins);
+
+	/* initialize binning counter and bounds */
+	BoundBox bin_bounds[MAX_BINS][4];	/* bounds for every bin in every dimension */
+	int4 bin_count[MAX_BINS];			/* number of primitives mapped to bin */
+
+	for(size_t i = 0; i < num_bins; i++) {
+		bin_count[i] = make_int4(0);
+		bin_bounds[i][0] = bin_bounds[i][1] = bin_bounds[i][2] = BoundBox::empty;
+	}
+
+	/* map geometry to bins, unrolled once */
+	{
+		ssize_t i;
+
+		for(i = 0; i < ssize_t(size()) - 1; i += 2) {
+			prefetch_L2(&prims[start() + i + 8]);
+
+			/* map even and odd primitive to bin */
+			BVHReference prim0 = prims[start() + i + 0];
+			BVHReference prim1 = prims[start() + i + 1];
+
+			int4 bin0 = get_bin(prim0.bounds());

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list