Godot Version
4.3.stable
Question
I’m rendering some 2D content into a SubViewport, and then using this viewport texture to draw in the main viewport. However, I’ve noticed that when drawing the content this way there seems to be a 1 frame delay, where the updated subviewport texture is shown on screen the next frame instead of the same frame that drawing was done. This is noticable since the updated drawn content follows the mouse cursor, and this causes it to drag behind ever so slightly. If I instead draw the same content directly in a control on the main viewport this 1 frame delay does not occur.
I’m guessing this is due to some issue with the rendering or updating order of the viewports. What I’d like is for the content in the subviewport to be rendered first, updating the viewport texture, so that this is then used in the same frame and rendered in the main viewport.
But it appears that either the viewport is rendered after, or the viewport texture is updated only at the end of the frame, causing the previous frame viewport texture to be used when rendering the main viewport? Or perhaps the update of the viewport texture is not correctly marking the control where it’s rendered as needing to redraw the same frame, causing the delay?
How can I set this up correctly to have the viewport texture be rendered the same frame as the rendering is done in the subviewport?