Fix #146133: Render Layers doesn't work in viewport

The Render Layers node doesn't work if a viewlayer other than the first
is selected. This was hard coded in code, so we just allow any view
layer, on the condition that it is the active one.

Pull Request: https://projects.blender.org/blender/blender/pulls/146285
This commit is contained in:
Omar Emara
2025-09-15 10:27:14 +02:00
committed by Omar Emara
parent 92b9c4c97d
commit 78e58bd595

View File

@@ -128,17 +128,20 @@ class Context : public compositor::Context {
return result;
}
compositor::Result get_input(const Scene *scene, int view_layer, const char *name) override
compositor::Result get_input(const Scene *scene, int view_layer_index, const char *name) override
{
/* Blender aliases the Image pass name to be the Combined pass, so we return the combined pass
* in that case. */
const char *pass_name = StringRef(name) == "Image" ? "Combined" : name;
if (DEG_get_original(scene) != DEG_get_original(scene_)) {
const Scene *original_scene = DEG_get_original(scene_);
if (DEG_get_original(scene) != original_scene) {
return compositor::Result(*this);
}
if (view_layer != 0) {
ViewLayer *view_layer = static_cast<ViewLayer *>(
BLI_findlink(&original_scene->view_layers, view_layer_index));
if (StringRef(view_layer->name) != DRW_context_get()->view_layer->name) {
return compositor::Result(*this);
}