diff options
author | Brecht Van Lommel <brecht@blender.org> | 2021-11-12 20:26:30 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-11-12 22:03:46 +0300 |
commit | ef0b8d6306e5e1cddf1d7a2087e5589adcf74172 (patch) | |
tree | 1fb8369fc17afa6f06f82b0ca14cf1209ca7e2c5 /intern | |
parent | 9d0d4b8601dfb9de335dd7af32562cbfb94238a6 (diff) |
Fix T92002: no Cycles combined baking support for filter settings
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/blender/session.cpp | 13 | ||||
-rw-r--r-- | intern/cycles/kernel/integrator/shade_surface.h | 2 | ||||
-rw-r--r-- | intern/cycles/kernel/integrator/shader_eval.h | 39 | ||||
-rw-r--r-- | intern/cycles/kernel/types.h | 14 | ||||
-rw-r--r-- | intern/cycles/scene/integrator.cpp | 29 | ||||
-rw-r--r-- | intern/cycles/scene/integrator.h | 7 |
6 files changed, 102 insertions, 2 deletions
diff --git a/intern/cycles/blender/session.cpp b/intern/cycles/blender/session.cpp index d9a2d3d3029..b7fd862bffd 100644 --- a/intern/cycles/blender/session.cpp +++ b/intern/cycles/blender/session.cpp @@ -606,6 +606,19 @@ void BlenderSession::bake(BL::Depsgraph &b_depsgraph_, pass->set_type(bake_type_to_pass(bake_type, bake_filter)); pass->set_include_albedo((bake_filter & BL::BakeSettings::pass_filter_COLOR)); + if (pass->get_type() == PASS_COMBINED) { + /* Filtering settings for combined pass. */ + Integrator *integrator = scene->integrator; + integrator->set_use_direct_light((bake_filter & BL::BakeSettings::pass_filter_DIRECT) != 0); + integrator->set_use_indirect_light((bake_filter & BL::BakeSettings::pass_filter_INDIRECT) != + 0); + integrator->set_use_diffuse((bake_filter & BL::BakeSettings::pass_filter_DIFFUSE) != 0); + integrator->set_use_glossy((bake_filter & BL::BakeSettings::pass_filter_GLOSSY) != 0); + integrator->set_use_transmission((bake_filter & BL::BakeSettings::pass_filter_TRANSMISSION) != + 0); + integrator->set_use_emission((bake_filter & BL::BakeSettings::pass_filter_EMIT) != 0); + } + session->set_display_driver(nullptr); session->set_output_driver(make_unique<BlenderOutputDriver>(b_engine)); diff --git a/intern/cycles/kernel/integrator/shade_surface.h b/intern/cycles/kernel/integrator/shade_surface.h index 3c84dcc3728..16a61c15f58 100644 --- a/intern/cycles/kernel/integrator/shade_surface.h +++ b/intern/cycles/kernel/integrator/shade_surface.h @@ -445,7 +445,7 @@ ccl_device bool integrate_surface(KernelGlobals kg, } #endif - shader_prepare_surface_closures(kg, state, &sd); + shader_prepare_surface_closures(kg, state, &sd, path_flag); #ifdef __HOLDOUT__ /* Evaluate holdout. */ diff --git a/intern/cycles/kernel/integrator/shader_eval.h b/intern/cycles/kernel/integrator/shader_eval.h index 68f1ef8c118..2560b71dc32 100644 --- a/intern/cycles/kernel/integrator/shader_eval.h +++ b/intern/cycles/kernel/integrator/shader_eval.h @@ -105,8 +105,45 @@ ccl_device_inline void shader_copy_volume_phases(ccl_private ShaderVolumePhases ccl_device_inline void shader_prepare_surface_closures(KernelGlobals kg, ConstIntegratorState state, - ccl_private ShaderData *sd) + ccl_private ShaderData *sd, + const uint32_t path_flag) { + /* Filter out closures. */ + if (kernel_data.integrator.filter_closures) { + if (kernel_data.integrator.filter_closures & FILTER_CLOSURE_EMISSION) { + sd->closure_emission_background = zero_float3(); + } + + if (kernel_data.integrator.filter_closures & FILTER_CLOSURE_DIRECT_LIGHT) { + sd->flag &= ~SD_BSDF_HAS_EVAL; + } + + if (path_flag & PATH_RAY_CAMERA) { + for (int i = 0; i < sd->num_closure; i++) { + ccl_private ShaderClosure *sc = &sd->closure[i]; + + if (CLOSURE_IS_BSDF_DIFFUSE(sc->type)) { + if (kernel_data.integrator.filter_closures & FILTER_CLOSURE_DIFFUSE) { + sc->type = CLOSURE_NONE_ID; + sc->sample_weight = 0.0f; + } + } + else if (CLOSURE_IS_BSDF_GLOSSY(sc->type)) { + if (kernel_data.integrator.filter_closures & FILTER_CLOSURE_GLOSSY) { + sc->type = CLOSURE_NONE_ID; + sc->sample_weight = 0.0f; + } + } + else if (CLOSURE_IS_BSDF_TRANSMISSION(sc->type)) { + if (kernel_data.integrator.filter_closures & FILTER_CLOSURE_TRANSMISSION) { + sc->type = CLOSURE_NONE_ID; + sc->sample_weight = 0.0f; + } + } + } + } + } + /* Defensive sampling. * * We can likely also do defensive sampling at deeper bounces, particularly diff --git a/intern/cycles/kernel/types.h b/intern/cycles/kernel/types.h index 2827139d511..4d4246d2a74 100644 --- a/intern/cycles/kernel/types.h +++ b/intern/cycles/kernel/types.h @@ -430,6 +430,16 @@ typedef struct BsdfEval { float3 glossy; } BsdfEval; +/* Closure Filter */ + +typedef enum FilterClosures { + FILTER_CLOSURE_EMISSION = (1 << 0), + FILTER_CLOSURE_DIFFUSE = (1 << 1), + FILTER_CLOSURE_GLOSSY = (1 << 2), + FILTER_CLOSURE_TRANSMISSION = (1 << 3), + FILTER_CLOSURE_DIRECT_LIGHT = (1 << 4), +} FilterClosures; + /* Shader Flag */ typedef enum ShaderFlag { @@ -1186,7 +1196,11 @@ typedef struct KernelIntegrator { int has_shadow_catcher; float scrambling_distance; + /* Closure filter. */ + int filter_closures; + /* padding */ + int pad1, pad2, pad3; } KernelIntegrator; static_assert_align(KernelIntegrator, 16); diff --git a/intern/cycles/scene/integrator.cpp b/intern/cycles/scene/integrator.cpp index e9ff868c3fc..737db8b98d5 100644 --- a/intern/cycles/scene/integrator.cpp +++ b/intern/cycles/scene/integrator.cpp @@ -63,6 +63,14 @@ NODE_DEFINE(Integrator) SOCKET_BOOLEAN(caustics_reflective, "Reflective Caustics", true); SOCKET_BOOLEAN(caustics_refractive, "Refractive Caustics", true); SOCKET_FLOAT(filter_glossy, "Filter Glossy", 0.0f); + + SOCKET_BOOLEAN(use_direct_light, "Use Direct Light", true); + SOCKET_BOOLEAN(use_indirect_light, "Use Indirect Light", true); + SOCKET_BOOLEAN(use_diffuse, "Use Diffuse", true); + SOCKET_BOOLEAN(use_glossy, "Use Glossy", true); + SOCKET_BOOLEAN(use_transmission, "Use Transmission", true); + SOCKET_BOOLEAN(use_emission, "Use Emission", true); + SOCKET_INT(seed, "Seed", 0); SOCKET_FLOAT(sample_clamp_direct, "Sample Clamp Direct", 0.0f); SOCKET_FLOAT(sample_clamp_indirect, "Sample Clamp Indirect", 0.0f); @@ -184,6 +192,27 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene kintegrator->caustics_refractive = caustics_refractive; kintegrator->filter_glossy = (filter_glossy == 0.0f) ? FLT_MAX : 1.0f / filter_glossy; + kintegrator->filter_closures = 0; + if (!use_direct_light) { + kintegrator->filter_closures |= FILTER_CLOSURE_DIRECT_LIGHT; + } + if (!use_indirect_light) { + kintegrator->min_bounce = 1; + kintegrator->max_bounce = 1; + } + if (!use_diffuse) { + kintegrator->filter_closures |= FILTER_CLOSURE_DIFFUSE; + } + if (!use_glossy) { + kintegrator->filter_closures |= FILTER_CLOSURE_GLOSSY; + } + if (!use_transmission) { + kintegrator->filter_closures |= FILTER_CLOSURE_TRANSMISSION; + } + if (!use_emission) { + kintegrator->filter_closures |= FILTER_CLOSURE_EMISSION; + } + kintegrator->seed = seed; kintegrator->sample_clamp_direct = (sample_clamp_direct == 0.0f) ? FLT_MAX : diff --git a/intern/cycles/scene/integrator.h b/intern/cycles/scene/integrator.h index 75764bcdedc..464d96ca01b 100644 --- a/intern/cycles/scene/integrator.h +++ b/intern/cycles/scene/integrator.h @@ -56,6 +56,13 @@ class Integrator : public Node { NODE_SOCKET_API(bool, caustics_refractive) NODE_SOCKET_API(float, filter_glossy) + NODE_SOCKET_API(bool, use_direct_light); + NODE_SOCKET_API(bool, use_indirect_light); + NODE_SOCKET_API(bool, use_diffuse); + NODE_SOCKET_API(bool, use_glossy); + NODE_SOCKET_API(bool, use_transmission); + NODE_SOCKET_API(bool, use_emission); + NODE_SOCKET_API(int, seed) NODE_SOCKET_API(float, sample_clamp_direct) |