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

Temporarily stop rendering 2D/3D views when unfocused #10042

Open
Sectonid opened this issue Jun 26, 2024 · 6 comments
Open

Temporarily stop rendering 2D/3D views when unfocused #10042

Sectonid opened this issue Jun 26, 2024 · 6 comments

Comments

@Sectonid
Copy link

Sectonid commented Jun 26, 2024

Describe the project you are working on

A winter-themed game, menu of which has a lot of 3D particles resembling snowflakes

Describe the problem or limitation you are having in your project

I have a laptop without a dedicated GPU with two screens, and when i focus to a different app (Chrome), the 3D view starts to struggle (GPU time increases from ~8 ms and 109 fps to ~36 ms and 33 fps), which i don't like to see, considering this is a laptop with a battery and not a PC.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

It will consume less resources when the editor is unfocused

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

When user moves focus to another window, the 2D/3D Views stop rendering. However, when it's focused to another window OF the Godot Engine's Editor, then it will keep renderint (useful when writing tool scripts or shaders!)
Here's the concept art that i did:
UnfocusedRendering_ConceptArt

If this enhancement will not be used often, can it be worked around with a few lines of script?

I don't think so...

Is there a reason why this should be core and not an add-on in the asset library?

This will improve laptop's performance

@AThousandShips

This comment was marked as outdated.

@Mickeon
Copy link

Mickeon commented Jun 26, 2024

Related to #2001

Your GPU settings should have "FPS when out-of-focus" setting for each application you run. It should work with Godot too (I know it does for me).

I think completely halting rendering would be quite disorienting, so it should probably be an FPS slider of sorts.

Edit: @Calinou was in fact working on this godotengine/godot#47812 , but it was never merged.

@Zireael07
Copy link

Your GPU settings should have "FPS when out-of-focus"

Which GPU/drivers is that? I never had such a setting on any computer I owned, not AMD, not NVIDIA...

@AThousandShips
Copy link
Member

AThousandShips commented Jun 26, 2024

Indeed my bad thought the suggestion was for having it happen when focusing other Godot windows, this is a bug I believe, the editor already supports this, but it breaks in some hardware and OSs, the editor should not process and redraw when unfocused:

// Set a low FPS cap to decrease CPU/GPU usage while the editor is unfocused.
OS::get_singleton()->set_low_processor_usage_mode_sleep_usec(int(EDITOR_GET("interface/editor/unfocused_low_processor_mode_sleep_usec")));

@Sectonid
Copy link
Author

Your GPU settings should have "FPS when out-of-focus" setting for each application you run.

Well, as i said i don't have a dedicated GPU in my laptop so i bet that i'll find it in a Control Panel for my Integrated graphics if there even is one

I think completely halting rendering would be quite disorienting, so it should probably be an FPS slider of sorts.

Perhaps we can get add an FPS limiter that if you set it to 0, then you'll see what i did in the concept art (i apologize for my bad English here).

@Calinou
Copy link
Member

Calinou commented Jun 26, 2024

I think #942 is a better solution to this problem. It's already in place in 3.5 (enable Vital Updates Only in the Editor Settings or by clicking the update spinner if it's shown), but hasn't been ported to 4.x yet.

As a workaround, hide your particles in the editor and show() them in a script.

the editor should not process and redraw when unfocused:

It should if there's animated content in its viewport, such as an active AnimationPlayer/AnimationTree, particles, or a shader using TIME. One exception to this rule is with the aforementioned Vital Updates Only option, which specifically ignores these redraw requests (and only those).

@Sectonid Sectonid changed the title Stop rendering 2D/3D views when unfocused Temporarily stop rendering 2D/3D views when unfocused Jun 29, 2024
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