diff options
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/blender/session.cpp | 31 | ||||
-rw-r--r-- | intern/cycles/kernel/integrator/init_from_bake.h | 8 | ||||
-rw-r--r-- | intern/cycles/kernel/integrator/shader_eval.h | 29 | ||||
-rw-r--r-- | intern/cycles/kernel/types.h | 3 | ||||
-rw-r--r-- | intern/cycles/scene/integrator.cpp | 9 |
5 files changed, 46 insertions, 34 deletions
diff --git a/intern/cycles/blender/session.cpp b/intern/cycles/blender/session.cpp index b8ac437443b..2c4e57404b8 100644 --- a/intern/cycles/blender/session.cpp +++ b/intern/cycles/blender/session.cpp @@ -606,19 +606,6 @@ 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)); @@ -628,6 +615,24 @@ void BlenderSession::bake(BL::Depsgraph &b_depsgraph_, sync->sync_camera(b_render, b_camera_override, width, height, ""); sync->sync_data( b_render, b_depsgraph, b_v3d, b_camera_override, width, height, &python_thread_state); + + /* Filtering settings for combined pass. */ + if (pass->get_type() == PASS_COMBINED) { + 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); + } + + /* Always use transpanent background for baking. */ + scene->background->set_transparent(true); + + /* Load built-in images from Blender. */ builtin_images_load(); } diff --git a/intern/cycles/kernel/integrator/init_from_bake.h b/intern/cycles/kernel/integrator/init_from_bake.h index df1c7fd07e7..f4a2fbea405 100644 --- a/intern/cycles/kernel/integrator/init_from_bake.h +++ b/intern/cycles/kernel/integrator/init_from_bake.h @@ -71,14 +71,16 @@ ccl_device bool integrator_init_from_bake(KernelGlobals kg, /* Setup render buffers. */ const int index = INTEGRATOR_STATE(state, path, render_pixel_index); const int pass_stride = kernel_data.film.pass_stride; - render_buffer += index * pass_stride; + ccl_global float *buffer = render_buffer + index * pass_stride; - ccl_global float *primitive = render_buffer + kernel_data.film.pass_bake_primitive; - ccl_global float *differential = render_buffer + kernel_data.film.pass_bake_differential; + ccl_global float *primitive = buffer + kernel_data.film.pass_bake_primitive; + ccl_global float *differential = buffer + kernel_data.film.pass_bake_differential; const int seed = __float_as_uint(primitive[0]); int prim = __float_as_uint(primitive[1]); if (prim == -1) { + /* Accumulate transparency for empty pixels. */ + kernel_accum_transparent(kg, state, 0, 1.0f, buffer); return false; } diff --git a/intern/cycles/kernel/integrator/shader_eval.h b/intern/cycles/kernel/integrator/shader_eval.h index 169a01d0797..2dcba73561d 100644 --- a/intern/cycles/kernel/integrator/shader_eval.h +++ b/intern/cycles/kernel/integrator/shader_eval.h @@ -122,23 +122,20 @@ ccl_device_inline void shader_prepare_surface_closures(KernelGlobals kg, 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; - } + if ((CLOSURE_IS_BSDF_DIFFUSE(sc->type) && + (kernel_data.integrator.filter_closures & FILTER_CLOSURE_DIFFUSE)) || + (CLOSURE_IS_BSDF_GLOSSY(sc->type) && + (kernel_data.integrator.filter_closures & FILTER_CLOSURE_GLOSSY)) || + (CLOSURE_IS_BSDF_TRANSMISSION(sc->type) && + (kernel_data.integrator.filter_closures & FILTER_CLOSURE_TRANSMISSION))) { + 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; - } + else if ((CLOSURE_IS_BSDF_TRANSPARENT(sc->type) && + (kernel_data.integrator.filter_closures & FILTER_CLOSURE_TRANSPARENT))) { + sc->type = CLOSURE_HOLDOUT_ID; + sc->sample_weight = 0.0f; + sd->flag |= SD_HOLDOUT; } } } diff --git a/intern/cycles/kernel/types.h b/intern/cycles/kernel/types.h index e66c3fe49df..4a730dbfaaa 100644 --- a/intern/cycles/kernel/types.h +++ b/intern/cycles/kernel/types.h @@ -431,7 +431,8 @@ typedef enum FilterClosures { FILTER_CLOSURE_DIFFUSE = (1 << 1), FILTER_CLOSURE_GLOSSY = (1 << 2), FILTER_CLOSURE_TRANSMISSION = (1 << 3), - FILTER_CLOSURE_DIRECT_LIGHT = (1 << 4), + FILTER_CLOSURE_TRANSPARENT = (1 << 4), + FILTER_CLOSURE_DIRECT_LIGHT = (1 << 5), } FilterClosures; /* Shader Flag */ diff --git a/intern/cycles/scene/integrator.cpp b/intern/cycles/scene/integrator.cpp index 9216a8ae615..31e645c1f3a 100644 --- a/intern/cycles/scene/integrator.cpp +++ b/intern/cycles/scene/integrator.cpp @@ -14,11 +14,13 @@ * limitations under the License. */ -#include "scene/integrator.h" #include "device/device.h" + #include "scene/background.h" +#include "scene/bake.h" #include "scene/camera.h" #include "scene/film.h" +#include "scene/integrator.h" #include "scene/jitter.h" #include "scene/light.h" #include "scene/object.h" @@ -230,6 +232,11 @@ void Integrator::device_update(Device *device, DeviceScene *dscene, Scene *scene if (!use_emission) { kintegrator->filter_closures |= FILTER_CLOSURE_EMISSION; } + if (scene->bake_manager->get_baking()) { + /* Baking does not need to trace through transparency, we only want to bake + * the object itself. */ + kintegrator->filter_closures |= FILTER_CLOSURE_TRANSPARENT; + } kintegrator->seed = seed; |