Fix: Grease Pencil not visible when using compositor

Grease Pencil objects are not visible when using the viewport
compositor. That's because since the introduction of multi-pass
compositing, the compositor now access the combined pass written by
EEVEE, which does not include GP.

To fix this, we skip writing the EEVEE combined pass, then read the
viewport texture for the combined pass as a special case, which should
include GP.
This commit is contained in:
Omar Emara
2024-07-26 10:29:00 +03:00
parent b73d8595bb
commit 945f7f5e23
2 changed files with 20 additions and 5 deletions

View File

@@ -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

View File

@@ -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<std::string> 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);