forked from bartvdbraak/blender
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.
This commit is contained in:
parent
d16a608f6d
commit
9d3ad07f14
@ -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",
|
||||
|
@ -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"
|
||||
|
@ -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);
|
||||
|
@ -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__
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -34,6 +34,8 @@ public:
|
||||
|
||||
bool use;
|
||||
|
||||
uint visibility;
|
||||
|
||||
bool transparent;
|
||||
bool need_update;
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user