Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viewport doesn't update when ViewportContainer is Hidden #57901

Closed
starcin opened this issue Feb 10, 2022 · 8 comments
Closed

Viewport doesn't update when ViewportContainer is Hidden #57901

starcin opened this issue Feb 10, 2022 · 8 comments

Comments

@starcin
Copy link

starcin commented Feb 10, 2022

Godot version

3.4.2.stable

System information

Windows 10, GLES3

Issue description

I've tried this in a 3D scene with a Control scene as a child (acting as overlay GUI).

Control scene has a TabContainer and one of the tabs has a ViewportContainer. ViewportContainer has a Viewport and the Viewport has a Camera (3D Camera).

The purpose is having a topview window in that tab.

I tried accessing the viewport.get_texture() in the main scene and saw that if I am showing another tab (ViewportContainer is not visible), the texture is not updated.

A simpler test I did was simply adding a ViewportContainer to my 3D scene and adding a sprite with ViewportTexture.
While running the game, if I hide the ViewportContainer in editor, the texture on the sprite stops updating.

I verified the Viewport render_target_update_mode is "Always" on both cases.

Steps to reproduce

Add a ViewportContainer with a viewport and camera to a 3D scene with some movement going on.
Add a sprite with ViewportTexture and show the viewport as target.
While running the game, hide the ViewportContainer in editor, you'll see the texture on the sprite stops updating.

Minimal reproduction project

EDIT: Created this issue at work and wasn't allowed to upload anything to internet there. Now the minimal project is added (after reminded by @akien-mga, so thanks :) )
minimal-viewport-update.zip

@TheDuriel
Copy link
Contributor

TheDuriel commented Feb 10, 2022

Not quite a bug? If it's not visible, then it will not render. And with a ViewportContainer, it is assumed that you are not using it elsewhere. You can however force it to. https://docs.godotengine.org/en/stable/classes/class_viewport.html#class-viewport-method-update-worlds

@akien-mga
Copy link
Member

akien-mga commented Feb 10, 2022

I think you can set the update mode to UPDATE_ALWAYS (default is UPDATE_WHEN_VISIBLE).
https://docs.godotengine.org/en/stable/classes/class_viewport.html#enum-viewport-updatemode

@starcin
Copy link
Author

starcin commented Feb 10, 2022

I don't know why this is closed since I clearly wrote:
"I verified the Viewport render_target_update_mode is "Always" on both cases." in my original post.
@akien-mga

@akien-mga
Copy link
Member

A minimal reproduction project would be good so that we can test and see if it's a bug or a misconfiguration.

@starcin
Copy link
Author

starcin commented Feb 11, 2022

Added the project to the original post. Thanks for reminding me. I was at work and wasn't allowed to upload anything.

@KoBeWi
Copy link
Member

KoBeWi commented Oct 30, 2023

ViewportContainer automatically changes update mode.

@BastiaanOlij
Copy link
Contributor

If I recall correctly a viewport container always overrules the update mode of the subviewport, this was done because many people left the subviewport set to rendering even when the container was hidden.

If you want to use the subviewport both shown as is, and as a texture on a 3D model, best not to use a subviewport but just display it on a textureRect.

@KoBeWi
Copy link
Member

KoBeWi commented Oct 30, 2023

Closing as duplicate of #56502
I have a PR that resolves this issue.

@KoBeWi KoBeWi closed this as not planned Won't fix, can't repro, duplicate, stale Oct 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants