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

[3D] Severe lag when running a scene with shadow resolution of 16384 and WorldEnvironment, yet the editor is fine. #64582

Closed
Y-VRN opened this issue Aug 18, 2022 · 1 comment

Comments

@Y-VRN
Copy link

Y-VRN commented Aug 18, 2022

Godot version

3.5.stable.official (991bb6a)

System information

Windows 10 Home 21H1, Intel Core i5-8250U, GLES3, NVIDIA GeForce MX130, 8GB RAM and 2GB VRAM

Issue description

I expect the game to run just as fast as the editor's preview.

https://user-images.githubusercontent.com/97438474/185447763-9a22bd8f-de56-45ea-ad1f-4ee549f1dbc9.mp4
(i messed up the recording, whoops)

Running a scene with a shadow resolution of 16384 causes FPS to drop to 30 or below, with slow load times (splash screen is skipped sometimes) and the possibility of actually crashing the editor (not always). This also causes background sounds (e.g. music from a web browser) to distort, although that could be due to the fact I have other processes running. GPU would max to 100%, or stutter from 0 to 100 and vice versa (perhaps readying the scene for one frame was having issues). Apparently, WorldEnvironment increases the lag as well. The most severe I got was the game would run even less than 1 FPS, and then speed up to 30-60 for a minimum of 1 second.

All these occurrences do not show up in the editor. The editor only uses 50-70%.

Reducing shadow resolution to 8192 still causes noticeable, but lesser lag.

The scene in which this occurred was very simple: flat materials (only albedo) WorldEnvironment with SSAO, bloom, and procedural sky, a controllable character, a large platform to walk on, and some obstacles for physics testing.

Attempting to change DirectionalLight from Optimized to Stable does not help. Setting Shader Compilation Mode in Project Settings to Async + Cache did nothing either. Even removing my character did no help. Setting the resolution is the only solution, but I don't find it acceptable.

Steps to reproduce

Preparing an empty baseplate with a bunch of objects and one DirectionalLight should already be sufficient.

Set the shadow resolution to 16384, or higher if the editor still hasn't stuttered.

WorldEnvironment also increases lag too, perhaps with Bloom, Procedural Sky, and SSAO (heaviest effect).

To much better visualize, have a controllable camera or a fast day/night cycle (using DirectionalLight).

Try running the game.

Minimal reproduction project

This is the simplest I could get the lag to show: A baseplate, a bunch of cubes for showing shadows, a spinning DirectionalLight (day/night cycle), and shadow resolution at 16384. The key to seeing the lag is to have a high-resolution shadow, still enough to be fast in the editor, but slow enough to cause problems when running the project.

GD 3.5 MRP 1 8.19.2022.zip

@Calinou
Copy link
Member

Calinou commented Aug 18, 2022

I expect the game to run just as fast as the editor's preview.

This can only happen if you still have VRAM available. Unfortunately, you're running out of VRAM by having two Godot instances run with very high shadow settings at the same time. You could avoid having to run the editor at the same time as the project by running the project from the command line, but you'll lose on debugging functionality.

Even on GPUs with 8 GB of VRAM, 16K shadows will be very intensive in terms of memory usage. A 24-bit 16384×16384 texture requires 805 MB of video memory, so if you have two running Godot instances, this requires 1,610 MB of video memory. On your GPU, this leaves less than 390 MB available for both Godot instances (195 MB per instance), which is unfortunately too little for modern 3D engines. This memory usage could be decreased by 33% by using 16-bit shadow maps, but it would still be too much for a GPU of your caliber.

Note that since Godot 3.5 allows you to change the directional shadow size at run-time, you could keep the directional shadow size project setting to its default value of 4096 and set it in a script to a higher resolution. This way, the higher shadow resolution will only be used in the running project.

Setting the resolution is the only solution, but I don't find it acceptable.

See setup recommendations in 3D lights and shadows to improve quality without increasing the performance requirements too much. Increasing the shadow resolution shouldn't be required in all but the most extreme cases (such as large open worlds where you need detailed shadows in the distance).

Closing, as this is ultimately a hardware issue (albeit with workarounds, as described above).

@Calinou Calinou closed this as not planned Won't fix, can't repro, duplicate, stale Aug 18, 2022
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

2 participants