Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2021-11-18 19:58:26 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-11-18 19:58:26 +0300
commitada6742601a715ee0d078cd693ba303a8286e1bd (patch)
tree1027d79363821162f50ef4948552119f7491c738
parent701f2dfd5bc61c0f37603880fa21abfe8b1d9620 (diff)
parent7c4e4d605c5f7390292586131e126e412e443029 (diff)
Merge remote-tracking branch 'origin/blender-v3.0-release'
-rw-r--r--intern/cycles/blender/session.cpp31
-rw-r--r--intern/cycles/kernel/integrator/init_from_bake.h8
-rw-r--r--intern/cycles/kernel/integrator/shader_eval.h29
-rw-r--r--intern/cycles/kernel/types.h3
-rw-r--r--intern/cycles/scene/integrator.cpp9
-rw-r--r--release/scripts/startup/bl_ui/properties_view_layer.py6
-rw-r--r--source/blender/editors/armature/pose_lib_2.c4
-rw-r--r--source/blender/render/intern/engine.c44
8 files changed, 76 insertions, 58 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;
diff --git a/release/scripts/startup/bl_ui/properties_view_layer.py b/release/scripts/startup/bl_ui/properties_view_layer.py
index ad7d6008238..3ced6a31db5 100644
--- a/release/scripts/startup/bl_ui/properties_view_layer.py
+++ b/release/scripts/startup/bl_ui/properties_view_layer.py
@@ -192,8 +192,10 @@ class ViewLayerCryptomattePanel(ViewLayerButtonsPanel, Panel):
view_layer.use_pass_cryptomatte_material,
view_layer.use_pass_cryptomatte_asset))
col.prop(view_layer, "pass_cryptomatte_depth", text="Levels")
- col.prop(view_layer, "use_pass_cryptomatte_accurate",
- text="Accurate Mode")
+
+ if context.engine == 'BLENDER_EEVEE':
+ col.prop(view_layer, "use_pass_cryptomatte_accurate",
+ text="Accurate Mode")
class VIEWLAYER_PT_layer_passes_cryptomatte(ViewLayerCryptomattePanel, Panel):
diff --git a/source/blender/editors/armature/pose_lib_2.c b/source/blender/editors/armature/pose_lib_2.c
index 002a4f74037..e7cbde0b239 100644
--- a/source/blender/editors/armature/pose_lib_2.c
+++ b/source/blender/editors/armature/pose_lib_2.c
@@ -562,7 +562,7 @@ static bool poselib_blend_poll(bContext *C)
void POSELIB_OT_apply_pose_asset(wmOperatorType *ot)
{
/* Identifiers: */
- ot->name = "Apply Pose Library Pose";
+ ot->name = "Apply Pose Asset";
ot->idname = "POSELIB_OT_apply_pose_asset";
ot->description = "Apply the given Pose Action to the rig";
@@ -595,7 +595,7 @@ void POSELIB_OT_blend_pose_asset(wmOperatorType *ot)
PropertyRNA *prop;
/* Identifiers: */
- ot->name = "Blend Pose Library Pose";
+ ot->name = "Blend Pose Asset";
ot->idname = "POSELIB_OT_blend_pose_asset";
ot->description = "Blend the given Pose Action to the rig";
diff --git a/source/blender/render/intern/engine.c b/source/blender/render/intern/engine.c
index 5f8679b572d..cb92b15f873 100644
--- a/source/blender/render/intern/engine.c
+++ b/source/blender/render/intern/engine.c
@@ -206,8 +206,8 @@ static RenderResult *render_result_from_bake(RenderEngine *engine, int x, int y,
BLI_addtail(&rr->layers, rl);
/* Add render passes. */
- RenderPass *result_pass = render_layer_add_pass(
- rr, rl, engine->bake.depth, RE_PASSNAME_COMBINED, "", "RGBA", true);
+ render_layer_add_pass(rr, rl, engine->bake.depth, RE_PASSNAME_COMBINED, "", "RGBA", true);
+
RenderPass *primitive_pass = render_layer_add_pass(rr, rl, 4, "BakePrimitive", "", "RGBA", true);
RenderPass *differential_pass = render_layer_add_pass(
rr, rl, 4, "BakeDifferential", "", "RGBA", true);
@@ -244,15 +244,6 @@ static RenderResult *render_result_from_bake(RenderEngine *engine, int x, int y,
}
}
- /* Initialize tile render result from full image bake result. */
- for (int ty = 0; ty < h; ty++) {
- size_t offset = ty * w * engine->bake.depth;
- size_t bake_offset = ((y + ty) * engine->bake.width + x) * engine->bake.depth;
- size_t size = w * engine->bake.depth * sizeof(float);
-
- memcpy(result_pass->rect + offset, engine->bake.result + bake_offset, size);
- }
-
return rr;
}
@@ -264,18 +255,31 @@ static void render_result_to_bake(RenderEngine *engine, RenderResult *rr)
return;
}
- /* Copy from tile render result to full image bake result. */
- int x = rr->tilerect.xmin;
- int y = rr->tilerect.ymin;
- int w = rr->tilerect.xmax - rr->tilerect.xmin;
- int h = rr->tilerect.ymax - rr->tilerect.ymin;
+ /* Copy from tile render result to full image bake result. Just the pixels for the
+ * object currently being baked, to preserve other objects when baking multiple. */
+ const int x = rr->tilerect.xmin;
+ const int y = rr->tilerect.ymin;
+ const int w = rr->tilerect.xmax - rr->tilerect.xmin;
+ const int h = rr->tilerect.ymax - rr->tilerect.ymin;
+ const size_t pixel_depth = engine->bake.depth;
+ const size_t pixel_size = pixel_depth * sizeof(float);
for (int ty = 0; ty < h; ty++) {
- size_t offset = ty * w * engine->bake.depth;
- size_t bake_offset = ((y + ty) * engine->bake.width + x) * engine->bake.depth;
- size_t size = w * engine->bake.depth * sizeof(float);
+ const size_t offset = ty * w;
+ const size_t bake_offset = (y + ty) * engine->bake.width + x;
- memcpy(engine->bake.result + bake_offset, rpass->rect + offset, size);
+ const float *pass_rect = rpass->rect + offset * pixel_depth;
+ const BakePixel *bake_pixel = engine->bake.pixels + bake_offset;
+ float *bake_result = engine->bake.result + bake_offset * pixel_depth;
+
+ for (int tx = 0; tx < w; tx++) {
+ if (bake_pixel->object_id == engine->bake.object_id) {
+ memcpy(bake_result, pass_rect, pixel_size);
+ }
+ pass_rect += pixel_depth;
+ bake_result += pixel_depth;
+ bake_pixel++;
+ }
}
}