I’m working on a moderately large scene (200x200 meters) and I’ve started having a lot of performance problems. A look at the visual profiler shows that my problem is CPU bound, and that the “Setup 3D Scene” section is taking a significant time to process.
Setting up the 3D scene is taking well over half the frame time, but it’s not giving me any insight into how I can optimize this, other than just removing things from the scene.
What exactly is the “Setup 3D Scene” section doing and how can I lower the time it takes to do it?
Update: I’ve found that things like SSR, SSAO, SSIL, and probably other WorldEnvironment settings contribute to this enigmatic “Setup 3D Scene.” (Oddly, it seems to be slower when turning off glow and fog…)
I’ve also noticed that things like TAA (both native and FSR2) add significant processing time to this process. Through some fine-tuning and concessions, I’ve gotten “Setup 3D Scene” from 3.83ms down to 2.53ms.
I could close this thread, but I’d like to keep it open because I’m still curious, what exactly does “Setup 3D Scene” encompass? I’ve found TAA and WorldEnvironment options affect it, so what else is within this vague field?
Update to the update: I have a SubViewport set to only render specific objects for some shader effects. The problem I was having was that I was setting a global shader parameter to the Viewport’s texture in the _process() function. Little did I realize that a SubViewport’s “get_texture()” method returns a special “dynamic Texture2D” that updates with the SubViewport, and so manually updating the global shader parameter was unneeded and was really stressing the bandwidth between my CPU and GPU.
I have gone from 150FPS to 185FPS with the WorldEnvironment tricks, and now I’ve gone from 185FPS to 430FPS, all because I was improperly using a global shader parameter. I think I’m going to mark this as solved now, I hope my findings can be helpful for someone else. Toodles!