diff --git a/source/blender/draw/engines/compositor/compositor_engine.cc b/source/blender/draw/engines/compositor/compositor_engine.cc index 4223447867e..f8f0ae3dadb 100644 --- a/source/blender/draw/engines/compositor/compositor_engine.cc +++ b/source/blender/draw/engines/compositor/compositor_engine.cc @@ -146,17 +146,25 @@ class Context : public realtime_compositor::Context { return nullptr; } + /* The combined pass is a special case where we return the viewport color texture, because it + * includes Grease Pencil objects since GP is drawn using their own engine. */ + if (STREQ(pass_name, RE_PASSNAME_COMBINED)) { + return DRW_viewport_texture_list_get()->color; + } + + /* Return the pass that was written by the engine if such pass was found. */ GPUTexture *pass_texture = DRW_viewport_pass_texture_get(pass_name).gpu_texture(); if (pass_texture) { return pass_texture; } - if (STREQ(pass_name, RE_PASSNAME_COMBINED)) { - return get_output_texture(); - } - else { - return nullptr; + /* If no Z pass was found above, return the viewport depth as a fallback, which might be + * populated if overlays are enabled. */ + if (STREQ(pass_name, RE_PASSNAME_Z)) { + return DRW_viewport_texture_list_get()->depth; } + + return nullptr; } StringRef get_view_name() const override diff --git a/source/blender/draw/engines/eevee_next/eevee_film.cc b/source/blender/draw/engines/eevee_next/eevee_film.cc index bba93a21b40..e3dfd36a55d 100644 --- a/source/blender/draw/engines/eevee_next/eevee_film.cc +++ b/source/blender/draw/engines/eevee_next/eevee_film.cc @@ -917,6 +917,13 @@ void Film::write_viewport_compositor_passes() continue; } + /* The compositor will use the viewport color texture as the combined pass because the viewport + * texture will include Grease Pencil, so no need to write the combined pass from the engine + * side. */ + if (pass_type == EEVEE_RENDER_PASS_COMBINED) { + continue; + } + Vector pass_names = Film::pass_to_render_pass_names(pass_type, inst_.view_layer); for (const int64_t pass_offset : IndexRange(pass_names.size())) { GPUTexture *pass_texture = this->get_pass_texture(pass_type, pass_offset);