From c5eb420c748a00ea17af055aa7e43655bb294d62 Mon Sep 17 00:00:00 2001 From: Omar Emara Date: Thu, 16 Nov 2023 15:04:47 +0200 Subject: [PATCH] Viewport Compositor: Allow access to depth pass This patch allows access to the depth pass in the Viewport Compositor. Since the depth information require full precision, making use of the pass requires the full precision option for now. In the future, this pass will always be stored using full precision regardless of the precision option. --- .../draw/engines/compositor/compositor_engine.cc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/source/blender/draw/engines/compositor/compositor_engine.cc b/source/blender/draw/engines/compositor/compositor_engine.cc index c632b56ff3d..13a30996526 100644 --- a/source/blender/draw/engines/compositor/compositor_engine.cc +++ b/source/blender/draw/engines/compositor/compositor_engine.cc @@ -161,12 +161,22 @@ class Context : public realtime_compositor::Context { GPUTexture *get_input_texture(const Scene *scene, int view_layer, const char *pass_name) override { - if ((DEG_get_original_id(const_cast(&scene->id)) == - DEG_get_original_id(&DRW_context_state_get()->scene->id)) && - view_layer == 0 && STREQ(pass_name, RE_PASSNAME_COMBINED)) + if (DEG_get_original_id(const_cast(&scene->id)) != + DEG_get_original_id(&DRW_context_state_get()->scene->id)) { + return nullptr; + } + + if (view_layer != 0) { + return nullptr; + } + + if (STREQ(pass_name, RE_PASSNAME_COMBINED)) { return get_output_texture(); } + else if (STREQ(pass_name, RE_PASSNAME_Z)) { + return DRW_viewport_texture_list_get()->depth; + } else { return nullptr; }