[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57363] trunk/blender/intern/cycles: Cycles: ray visibility panel is now also available for the world, works same as

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Jun 10 22:34:35 CEST 2013


Revision: 57363
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57363
Author:   blendix
Date:     2013-06-10 20:34:34 +0000 (Mon, 10 Jun 2013)
Log Message:
-----------
Cycles: ray visibility panel is now also available for the world, works same as
meshes and lamps. The light path node already made this possible but it's a bit
faster to render this way and convenient.

Modified Paths:
--------------
    trunk/blender/intern/cycles/blender/addon/properties.py
    trunk/blender/intern/cycles/blender/addon/ui.py
    trunk/blender/intern/cycles/blender/blender_shader.cpp
    trunk/blender/intern/cycles/kernel/kernel_emission.h
    trunk/blender/intern/cycles/kernel/kernel_types.h
    trunk/blender/intern/cycles/render/background.cpp
    trunk/blender/intern/cycles/render/background.h
    trunk/blender/intern/cycles/render/integrator.cpp

Modified: trunk/blender/intern/cycles/blender/addon/properties.py
===================================================================
--- trunk/blender/intern/cycles/blender/addon/properties.py	2013-06-10 20:10:03 UTC (rev 57362)
+++ trunk/blender/intern/cycles/blender/addon/properties.py	2013-06-10 20:34:34 UTC (rev 57363)
@@ -589,6 +589,12 @@
                 type=cls,
                 )
 
+        bpy.types.World.cycles_visibility = PointerProperty(
+                name="Cycles Visibility Settings",
+                description="Cycles visibility settings",
+                type=cls,
+                )
+
         cls.camera = BoolProperty(
                 name="Camera",
                 description="Object visibility for camera rays",

Modified: trunk/blender/intern/cycles/blender/addon/ui.py
===================================================================
--- trunk/blender/intern/cycles/blender/addon/ui.py	2013-06-10 20:10:03 UTC (rev 57362)
+++ trunk/blender/intern/cycles/blender/addon/ui.py	2013-06-10 20:34:34 UTC (rev 57363)
@@ -542,9 +542,11 @@
         flow.prop(visibility, "diffuse")
         flow.prop(visibility, "glossy")
         flow.prop(visibility, "transmission")
-        flow.prop(visibility, "shadow")
 
+        if ob.type != 'LAMP':
+            flow.prop(visibility, "shadow")
 
+
 def find_node(material, nodetype):
     if material and material.node_tree:
         ntree = material.node_tree
@@ -777,6 +779,29 @@
         layout.prop(world.mist_settings, "falloff")
 
 
+class CyclesWorld_PT_ray_visibility(CyclesButtonsPanel, Panel):
+    bl_label = "Ray Visibility"
+    bl_context = "world"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        return CyclesButtonsPanel.poll(context) and context.world
+
+    def draw(self, context):
+        layout = self.layout
+
+        world = context.world
+        visibility = world.cycles_visibility
+
+        flow = layout.column_flow()
+
+        flow.prop(visibility, "camera")
+        flow.prop(visibility, "diffuse")
+        flow.prop(visibility, "glossy")
+        flow.prop(visibility, "transmission")
+
+
 class CyclesWorld_PT_settings(CyclesButtonsPanel, Panel):
     bl_label = "Settings"
     bl_context = "world"

Modified: trunk/blender/intern/cycles/blender/blender_shader.cpp
===================================================================
--- trunk/blender/intern/cycles/blender/blender_shader.cpp	2013-06-10 20:10:03 UTC (rev 57362)
+++ trunk/blender/intern/cycles/blender/blender_shader.cpp	2013-06-10 20:34:34 UTC (rev 57363)
@@ -895,8 +895,8 @@
 			graph->connect(closure->output("Background"), out->input("Surface"));
 		}
 
-		/* AO */
 		if(b_world) {
+			/* AO */
 			BL::WorldLighting b_light = b_world.light_settings();
 
 			if(b_light.use_ambient_occlusion())
@@ -905,6 +905,17 @@
 				background->ao_factor = 0.0f;
 
 			background->ao_distance = b_light.distance();
+
+			/* visibility */
+			PointerRNA cvisibility = RNA_pointer_get(&b_world.ptr, "cycles_visibility");
+			uint visibility = 0;
+
+			visibility |= get_boolean(cvisibility, "camera")? PATH_RAY_CAMERA: 0;
+			visibility |= get_boolean(cvisibility, "diffuse")? PATH_RAY_DIFFUSE: 0;
+			visibility |= get_boolean(cvisibility, "glossy")? PATH_RAY_GLOSSY: 0;
+			visibility |= get_boolean(cvisibility, "transmission")? PATH_RAY_TRANSMIT: 0;
+
+			background->visibility = visibility;
 		}
 
 		shader->set_graph(graph);

Modified: trunk/blender/intern/cycles/kernel/kernel_emission.h
===================================================================
--- trunk/blender/intern/cycles/kernel/kernel_emission.h	2013-06-10 20:10:03 UTC (rev 57362)
+++ trunk/blender/intern/cycles/kernel/kernel_emission.h	2013-06-10 20:34:34 UTC (rev 57363)
@@ -199,12 +199,10 @@
 #ifdef __PASSES__
 	/* use visibility flag to skip lights */
 	if(ls.shader & SHADER_EXCLUDE_ANY) {
-		if((ls.shader & SHADER_EXCLUDE_DIFFUSE) && (path_flag & PATH_RAY_DIFFUSE))
+		if(((ls.shader & SHADER_EXCLUDE_DIFFUSE) && (path_flag & PATH_RAY_DIFFUSE)) ||
+		   ((ls.shader & SHADER_EXCLUDE_GLOSSY) && (path_flag & PATH_RAY_GLOSSY)) ||
+		   ((ls.shader & SHADER_EXCLUDE_TRANSMIT) && (path_flag & PATH_RAY_TRANSMIT)))
 			return false;
-		if((ls.shader & SHADER_EXCLUDE_GLOSSY) && (path_flag & PATH_RAY_GLOSSY))
-			return false;
-		if((ls.shader & SHADER_EXCLUDE_TRANSMIT) && (path_flag & PATH_RAY_TRANSMIT))
-			return false;
 	}
 #endif
 
@@ -229,9 +227,21 @@
 __device_noinline float3 indirect_background(KernelGlobals *kg, Ray *ray, int path_flag, float bsdf_pdf)
 {
 #ifdef __BACKGROUND__
+	int shader = kernel_data.background.shader;
+
+	/* use visibility flag to skip lights */
+	if(shader & SHADER_EXCLUDE_ANY) {
+		if(((shader & SHADER_EXCLUDE_DIFFUSE) && (path_flag & PATH_RAY_DIFFUSE)) ||
+		   ((shader & SHADER_EXCLUDE_GLOSSY) && (path_flag & PATH_RAY_GLOSSY)) ||
+		   ((shader & SHADER_EXCLUDE_TRANSMIT) && (path_flag & PATH_RAY_TRANSMIT)) ||
+		   ((shader & SHADER_EXCLUDE_CAMERA) && (path_flag & PATH_RAY_CAMERA)))
+			return make_float3(0.0f, 0.0f, 0.0f);
+	}
+
 	/* evaluate background closure */
 	ShaderData sd;
 	shader_setup_from_background(kg, &sd, ray);
+
 	float3 L = shader_eval_background(kg, &sd, path_flag, SHADER_CONTEXT_EMISSION);
 
 #ifdef __BACKGROUND_MIS__

Modified: trunk/blender/intern/cycles/kernel/kernel_types.h
===================================================================
--- trunk/blender/intern/cycles/kernel/kernel_types.h	2013-06-10 20:10:03 UTC (rev 57362)
+++ trunk/blender/intern/cycles/kernel/kernel_types.h	2013-06-10 20:34:34 UTC (rev 57363)
@@ -329,7 +329,8 @@
 	SHADER_EXCLUDE_DIFFUSE = (1 << 27),
 	SHADER_EXCLUDE_GLOSSY = (1 << 26),
 	SHADER_EXCLUDE_TRANSMIT = (1 << 25),
-	SHADER_EXCLUDE_ANY = (SHADER_EXCLUDE_DIFFUSE|SHADER_EXCLUDE_GLOSSY|SHADER_EXCLUDE_TRANSMIT),
+	SHADER_EXCLUDE_CAMERA = (1 << 24),
+	SHADER_EXCLUDE_ANY = (SHADER_EXCLUDE_DIFFUSE|SHADER_EXCLUDE_GLOSSY|SHADER_EXCLUDE_TRANSMIT|SHADER_EXCLUDE_CAMERA),
 
 	SHADER_MASK = ~(SHADER_SMOOTH_NORMAL|SHADER_CAST_SHADOW|SHADER_AREA_LIGHT|SHADER_USE_MIS|SHADER_EXCLUDE_ANY)
 } ShaderFlag;

Modified: trunk/blender/intern/cycles/render/background.cpp
===================================================================
--- trunk/blender/intern/cycles/render/background.cpp	2013-06-10 20:10:03 UTC (rev 57362)
+++ trunk/blender/intern/cycles/render/background.cpp	2013-06-10 20:34:34 UTC (rev 57363)
@@ -37,6 +37,8 @@
 
 	use = true;
 
+	visibility = ~0;
+
 	transparent = false;
 	need_update = true;
 }
@@ -64,6 +66,15 @@
 	else
 		kbackground->shader = scene->shader_manager->get_shader_id(scene->default_empty);
 
+	if(!(visibility & PATH_RAY_DIFFUSE))
+		kbackground->shader |= SHADER_EXCLUDE_DIFFUSE;
+	if(!(visibility & PATH_RAY_GLOSSY))
+		kbackground->shader |= SHADER_EXCLUDE_GLOSSY;
+	if(!(visibility & PATH_RAY_TRANSMIT))
+		kbackground->shader |= SHADER_EXCLUDE_TRANSMIT;
+	if(!(visibility & PATH_RAY_CAMERA))
+		kbackground->shader |= SHADER_EXCLUDE_CAMERA;
+
 	need_update = false;
 }
 
@@ -76,7 +87,8 @@
 	return !(transparent == background.transparent &&
 		use == background.use &&
 		ao_factor == background.ao_factor &&
-		ao_distance == background.ao_distance);
+		ao_distance == background.ao_distance &&
+		visibility == background.visibility);
 }
 
 void Background::tag_update(Scene *scene)

Modified: trunk/blender/intern/cycles/render/background.h
===================================================================
--- trunk/blender/intern/cycles/render/background.h	2013-06-10 20:10:03 UTC (rev 57362)
+++ trunk/blender/intern/cycles/render/background.h	2013-06-10 20:34:34 UTC (rev 57363)
@@ -34,6 +34,8 @@
 
 	bool use;
 
+	uint visibility;
+
 	bool transparent;
 	bool need_update;
 

Modified: trunk/blender/intern/cycles/render/integrator.cpp
===================================================================
--- trunk/blender/intern/cycles/render/integrator.cpp	2013-06-10 20:10:03 UTC (rev 57362)
+++ trunk/blender/intern/cycles/render/integrator.cpp	2013-06-10 20:34:34 UTC (rev 57363)
@@ -173,7 +173,8 @@
 		ao_samples == integrator.ao_samples &&
 		mesh_light_samples == integrator.mesh_light_samples &&
 		subsurface_samples == integrator.subsurface_samples &&
-		motion_blur == integrator.motion_blur);
+		motion_blur == integrator.motion_blur &&
+		sampling_pattern == integrator.sampling_pattern);
 }
 
 void Integrator::tag_update(Scene *scene)




More information about the Bf-blender-cvs mailing list