Rendering just some of a tree of Controls into another viewport

Godot Version

4.2

Question

I’m having a bit of a puzzle here, I’m trying to render just a few select elements of an existing tree of Controls into a separate framebuffer.

I can’t just use SubViewport and have my desired objects inside it, because I want them to interact with layout normally

I kinda figured out I can set a SubViewport to render the regular world, but I haven’t been able to get it to render just a couple layers while the root viewport renders everything but that layer

It looks like if I change the root viewport’s culling mask to not include the special element, then it’s culled too early, before the subviewport can get a chance to cull its own stuff

I guess i could instead use 2 subviewports with opposite culling masks, but that means godot is still rendering my Controls on the root viewport somewhere for a total of 3 (and I like my devices to be in the solid state of matter)

On the screenshot, I’d like to have the selected node only be rendered inside the SubViewport, not the normal viewport.

2024-08-08_20-50

I figured out that if I set my special object as top_level, then I get the rendering behaviour I want, but then it does not influence the layout calculation for the rest of the screen, which I also need.

Ok, I figured it out. The docs state:

The rendering layer in which this CanvasItem is rendered by Viewport nodes. A Viewport will render a CanvasItem if it and all its parents share a layer with the Viewport’s canvas cull mask.

So I had to add all intermediary objects in my hierarchy to the layer that I want to get rendered in the SubViewport.

This restricts my options, since it means if I used PanelContainer or other drawing objects in the hierarchy those would appear there too, but I don’t need that so this is sufficient for me.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.