Cycles: ray visibility panel is now also available for the world, works same as
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 10 Jun 2013 20:34:34 +0000 (20:34 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 10 Jun 2013 20:34:34 +0000 (20:34 +0000)
meshes and lamps. The light path node already made this possible but it's a bit
faster to render this way and convenient.

intern/cycles/blender/addon/properties.py
intern/cycles/blender/addon/ui.py
intern/cycles/blender/blender_shader.cpp
intern/cycles/kernel/kernel_emission.h
intern/cycles/kernel/kernel_types.h
intern/cycles/render/background.cpp
intern/cycles/render/background.h
intern/cycles/render/integrator.cpp

index 7ea8465976469c58fa8c61dee2d13859adeead57..0c6cf9f513a2dd0f8a3af9e06c6b63ebeb7636b8 100644 (file)
@@ -589,6 +589,12 @@ class CyclesVisibilitySettings(bpy.types.PropertyGroup):
                 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",
index 8950b4f83c41cef3dbe8e923ccf9325d06ad28d4..a30622a36ac4b542d9ec67c0d37fc0ae7229acf3 100644 (file)
@@ -542,7 +542,9 @@ class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
         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):
@@ -777,6 +779,29 @@ class CyclesWorld_PT_mist(CyclesButtonsPanel, Panel):
         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"
index 722b391958021f6eabcac1554897fbfd6862b06c..a5fe5dbf12f494744e95ea9672a05166c1a927b5 100644 (file)
@@ -895,8 +895,8 @@ void BlenderSync::sync_world(bool update_all)
                        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 @@ void BlenderSync::sync_world(bool update_all)
                                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);
index 869c853980908c8baae84c563bfe6e8fc2a4efc6..c430a40d814f9dfdb9002b34ce1f2b53af8749ce 100644 (file)
@@ -199,11 +199,9 @@ __device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int p
 #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))
-                       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))
+               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;
        }
 #endif
@@ -229,9 +227,21 @@ __device_noinline bool indirect_lamp_emission(KernelGlobals *kg, Ray *ray, int p
 __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__
index 9785f2e8320cc17acc8fbfac1146a73906912238..6ae3b10595c505499c59e4115e6bd6fb219207c0 100644 (file)
@@ -329,7 +329,8 @@ typedef enum ShaderFlag {
        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;
index 76d26dd34b57e60dd8b0d5b3b310aaade7bf4c13..3513665f256010fd77fde42d8b696b3956db6482 100644 (file)
@@ -37,6 +37,8 @@ Background::Background()
 
        use = true;
 
+       visibility = ~0;
+
        transparent = false;
        need_update = true;
 }
@@ -64,6 +66,15 @@ void Background::device_update(Device *device, DeviceScene *dscene, Scene *scene
        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 @@ bool Background::modified(const Background& background)
        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)
index 3c1cd3915e5e158ddd3feb172fc3ab028365b7df..e0c0c42de37149334a2245d90b6dc3a2672eb12b 100644 (file)
@@ -34,6 +34,8 @@ public:
 
        bool use;
 
+       uint visibility;
+
        bool transparent;
        bool need_update;
 
index cc369e7abc95e8b30469ad70699abb13859cee73..796746e828f046b06a2c6f701ff76605ed959713 100644 (file)
@@ -173,7 +173,8 @@ bool Integrator::modified(const Integrator& integrator)
                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)