From 9d3ad07f1417fdc959ee3d3e86a7bff1c2ee6d80 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 10 Jun 2013 20:34:34 +0000 Subject: 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. --- intern/cycles/blender/addon/properties.py | 6 ++++++ intern/cycles/blender/addon/ui.py | 27 ++++++++++++++++++++++++++- intern/cycles/blender/blender_shader.cpp | 13 ++++++++++++- intern/cycles/kernel/kernel_emission.h | 20 +++++++++++++++----- intern/cycles/kernel/kernel_types.h | 3 ++- intern/cycles/render/background.cpp | 14 +++++++++++++- intern/cycles/render/background.h | 2 ++ intern/cycles/render/integrator.cpp | 3 ++- 8 files changed, 78 insertions(+), 10 deletions(-) diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 7ea84659764..0c6cf9f513a 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -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", diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 8950b4f83c4..a30622a36ac 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -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" diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 722b3919580..a5fe5dbf12f 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -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); diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h index 869c8539809..c430a40d814 100644 --- a/intern/cycles/kernel/kernel_emission.h +++ b/intern/cycles/kernel/kernel_emission.h @@ -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__ diff --git a/intern/cycles/kernel/kernel_types.h b/intern/cycles/kernel/kernel_types.h index 9785f2e8320..6ae3b10595c 100644 --- a/intern/cycles/kernel/kernel_types.h +++ b/intern/cycles/kernel/kernel_types.h @@ -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; diff --git a/intern/cycles/render/background.cpp b/intern/cycles/render/background.cpp index 76d26dd34b5..3513665f256 100644 --- a/intern/cycles/render/background.cpp +++ b/intern/cycles/render/background.cpp @@ -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) diff --git a/intern/cycles/render/background.h b/intern/cycles/render/background.h index 3c1cd3915e5..e0c0c42de37 100644 --- a/intern/cycles/render/background.h +++ b/intern/cycles/render/background.h @@ -34,6 +34,8 @@ public: bool use; + uint visibility; + bool transparent; bool need_update; diff --git a/intern/cycles/render/integrator.cpp b/intern/cycles/render/integrator.cpp index cc369e7abc9..796746e828f 100644 --- a/intern/cycles/render/integrator.cpp +++ b/intern/cycles/render/integrator.cpp @@ -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) -- cgit v1.2.3