Rendering subwindows to SubViewport

Godot Version

4.2

Question

I am using a post-processing shader to scale pixel art. What I have currently works with my game world and GUI, except for things like Popups and the panels of OptionButtons. They bypass the shader, I am assuming because they are Windows and thus their own Viewports.

My main scene is set up as such:

  • Scene root (Node)
    • ColorRect (has ShaderMaterial applied)
    • SubViewport
      • Level scene (Node2D)
      • GUI layer (CanvasLayer)
        • All of my GUI elements (Controls, Popups)

The SubViewport is at a fixed size, which is the size that I want all graphics to render at for upscaling. I am using the SubViewport for its ViewportTexture, which I sample from in a shader applied to the ColorRect. display/window/stretch/mode is set to canvas_items in the project settings. This setup works perfectly for most things.

When I open an OptionButton, however, the popup with the options is not rendered into the ViewportTexture I use for my custom scaling. Instead, it is rendered to the screen using regular nearest neighbor filtering. The same applies to a Popup I want to use for a modal window.

This is more clearly visible if I change the shader to tint its output a red color; the options panel and the popup remain untinted.

Can I make it so these also render to the SubViewport so that they are post-processed by my shader?

Looking for any possible solution, I have tried setting the world_2d on the popup to the one from the SubViewport, but it did not help.
display/window/subwindows/embed_subwindows is enabled in my project settings, which is the default.

2024-08-13_16:09:28.375
2024-08-13_16:09:32.969

I believe I have found the solution: Viewports have the property gui_embed_subwindows, which seems to do what I want.

So all I need to do is turn on “Embed Subwindows” on my SubViewport.

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