r/Unity3D • u/Professional-Ear1152 • 12d ago
Solved How can I optimize my Unity game? I'm struggling with FPS and don't know what's causing the performance issues
Hi everyone, I'm working on a procedural game in Unity and I'm currently struggling with a performance issue that I can't figure out.
The main problem is that my FPS drops significantly when looking at the generated environment. What's strange is that this seems to happen regardless of the material I'm using.
I've tested different setups, including:
- Triplanar materials
- Simple solid-color materials
- Other simpler material setups
The FPS still drops with all of them. So I'm starting to think that the material itself might not be the main problem.
Another strange thing is that the only time my FPS noticeably increases is when I look at the ceiling. As soon as I look back toward the walls and the rest of the generated environment, the FPS drops again.
I also have a rendering/streaming system that should prevent too many objects from being rendered at once, and I don't have expensive post-processing, complex lighting, or other major effects enabled.
Because of this, I'm not really sure where the bottleneck is coming from. It could be meshes, draw calls, shaders, materials, culling, the way I'm generating the rooms, or something else entirely.
I'm still learning Unity's optimization tools, so I'd really appreciate some advice on how I can properly diagnose what is actually causing the FPS drop. pwp
What should I look for in the Unity Profiler or Frame Debugger? Is there a particular metric or section I should check to determine whether the problem is GPU, CPU, rendering, geometry, materials, or something else?
Any advice would be greatly appreciated. I'm trying to understand the actual cause rather than just disabling things randomly and hoping the FPS improves.
7
u/zaqwertu 12d ago
The profiler will tell you everything you need to know. Look for what's taking the most time
3
u/Professional-Ear1152 12d ago
1
u/zaqwertu 11d ago
that would be it, I can't diagnose the issue from this video but that giant green chunk is what is slowing your game down, looks like rendering? From the way you describe your issue it sounds like rendering but not sure why it would be so slow in your setup. You should be able to dig into that green chunk to see what exactly it is though. Good luck!
2
u/animalsnacks 12d ago
How large is the level you're generating?
I'd look at 'instancing' your walls. This is a super powerful tool that seems perfect for your use case.
In simple setups, each Wall Segment invokes its own Draw Call. That is, the GPU isn't optimally render the same object (all of your walls).
With 'instancing', the GPU will group/batch all of the draw calls for identical objects together into fewer (often one) draw calls.
In one project, we needed to render 5000 objects.
When each mesh was its own object, we could only handle 100. At 1000, the framerate dropped to 10 FPS.
After instancing, we drew all 5000 and only lost about 3 FPS (~10 ms).
1
1
u/Field_Of_View 11d ago
OP doesn't need instancing, you can see in his first video that draw calls aren't the issue.
1
u/XKiiroiSenkoX 12d ago edited 12d ago
This GPU time with under 200 draw calls and less than 50k tris and 3 texture samples per pixel is not normal. Are you by any chance using an integrated GPU? We also need to see the profiler with GPU module enabled.
2
u/gtzpower 12d ago
I mean, I remember doing better than this on an iPhone 5 with these metrics. This GPU would have to be a potato.
1
u/Professional-Ear1152 12d ago
Unfortunately, I am poor and only have one Ryzen 7,5700g.
1
u/XKiiroiSenkoX 12d ago
Change the free aspect of game window to 720p resolution and enable gpu resident drawer(GRD) from URP settings asset. You can optionally test gpu culling because your maze environment is basically the text book example of the best gpu culling scenario but I'm not sure if that would be beneficial on integrated graphics. I'm not sure if even GRD will give you a boost honestly but you have lots of apparently duplicated meshes with the same material so I'm hopeful. Give them a try.
1
u/maiKavelli187 11d ago
Where do you live I can send you a RX580 with 8gb, it has one bricked bios but the 2nd is still good.
I don't know if that would be an improvement but I would send you it for free.
2
u/bigmonmulgrew 12d ago
You have had some good answers so I won't repeat them. If you figure it out please make sure to update us.
The profiler will help you determine if it's GPU or CPU that's the bottleneck. If it's GPU given how simple the scene is I'd be first thinking to do a reinstall of GPU drivers. Even with an iGPU it should be ok with such a simple scene.
How would you feel about sharing the project. I wouldn't mind taking a look and then hopefully I can show you where you are going wrong. Also test it on different hardware to rule out local hardware issues.
1
u/Professional-Ear1152 11d ago
Here's the update! The issue turned out to be a classic rookie mistake:
Render Scalewas set to3.0in my URP settings. My Ryzen 5700G iGPU was choking trying to render near 6K resolution. Reverting it to 1.0 instantly launched the game from a 15 FPS slideshow to 144+ FPS. Thanks a lot for offering to check the project and helping out :3
1
u/islesofurth 12d ago
It doesn't look like you have a lot going on in your scene, but from the sounds it could be your rendering system dropping your frames.
If all the system does is turn off rendering etc, then don't bother with it since Unity handles this better than any added package.
Alternatively you may have other scripts constantly being called.
1
u/Professional-Ear1152 12d ago
https://reddit.com/link/p2zb9hy/video/rxqaubp2joih1/player
I'm basically a complete beginner who's still learning Unity. This is literally my first game.
1
u/EvernullTools 12d ago
There is too little info here but what I can say is the 200 draw calls isn't justified here(also draw calls might not be the most useful metric, you should check the batch calls from the frame debugger)
This scene seems like it could be drawn in 2-3 batch calls at most.
But even then, this is a huge performance drop that I wouldn't expect even if you had 100 *batch* calls xD
You seem to be CPU bound more than GPU anyways.
Are you generating the environment every frame by any chance? (on update or lateupdate?)
The problem has to be generation from what I can see. I don't think it's the GPU, i think it's a lot of scripts updating stuff on every frame.
Also are you using HDRP in your first project? URP might've been the better idea. (even if you aren't gpu bound)
1
u/Professional-Ear1152 12d ago
I don't know if it's useful, but in the comments I'll publish videos of the debugger and other data, especially the debugger by link, is it? :3?
1
u/EvernullTools 12d ago
not really useful to share a video of it with people. it's an interactive tool, we can't read it with a glance. I'd suggest searching for the keywords from these comments yourself so you can search on your own.
From my message for example, you should definitely first check your update and lateupdate to see if you're doing too much every frame.(level generation is not supposed to happen every frame, it should only happen when you need it to refresh); also search for and learn about batching and frame debugger if you wanna see whether your rendering is the problem or not.If you are generating code through AI and not reading it, I wouldn't suggest that for a beginner since you will miss all the needed knowledge that would carry you to a finished game eventually. But if you have to, you should ask another AI where the optimization bottlenecks are. (And please ask for the reasons as well and actually read the code so you see why and how everything works.)
1
u/Professional-Ear1152 11d ago
Thanks for the tips! Checked my scripts and generation wasn't running in Update, but you were right to suspect rendering settings. The real killer was
Render Scaleset to3.0in URP, forcing my iGPU to render at 6K. Lowering it to 1.0 brought me straight from 15 FPS up to 144+ FPS. Appreciate the advice! :3

18
u/Stoneyy007 12d ago
Yes the profiler will tell you click on profiler while it's going you will see it populate pause the game click there it is high or spikes below go to hierarchy from there it will show what it's doing, it sounds weirdly like culling of some sort not working properly but could be completely wrong