I have an issue where I have a very basic 3D scene/game (Android) and I have buttons to show and hide all of the content to test. The issue is I can lose 3/4 FPS out of 30 just turning on some basic effects. This takes me down to a laggy 10FPS when I have everything on. It makes me wonder whether I will be able to achieve 30FPS consistently throughout gameplay.
So my question is should I aim for max FPS, which is 30 for my phone, or do I just eyeball it and take what still looks reasonably good?
If you go below 30fps on a target device you’re only asking for trouble. You should look into mobile optimised effects because it sounds like you’re using desktop ones if a very basic scene (screenshots?) chugs like that. We also need to know what device you’re talking about.
I understand there’s a lot of particles going on and some I definitely need to improve but it seems as though I won’t be able to get to something half as good as this if I optimise it. I am using an old HTC M8 so the specs are relatively low end but a good baseline for performance.
Sub-30fps games which are not turn based will play badly. It’s that simple. Do you want to make something play badly? will a badly playing game sell? Questions anyone can answer.
The thing is 20FPS plays pretty well but now it seems like I should not be satisfied with 20 and must achieve 30, that was my question. i.e. Do not sacrifice FPS for graphics, not matter how small.
As this is my first real attempt at making a decent game I have a lot to learn about optimisation and feel I can improve the FPS so I will look to try and achieve 30 but may go to 20-25 at worst as it is still playable and will be fine on higher end mobiles. (Unless anyone thinks there is a problem with that strategy)
If your problem is that you have a low-end device, there’s at least hope that it will play well on most recent devices. You could try to test the FPS when launching the game and maybe lock the frame rate to a lower setting, because consistent rates are better than jumping all over the place.
This is why the quality settings exist. Just define your quality settings properly and adjust it when you’re on a lower end device. It won’t be that beautiful, but this is the price when someone wants to play your game on an old device. They are probably already used to the fact that their games aren’t looking that good than on the latest devices.
I actually use those as well but the majority of the FPS is lost on effects not things like shadows, textures or lights or any of the things those settings control. Unless you are referring to something else.
In your screenshot it looks like you might be using the built-in terrain system? If so, I don’t think that’s a good fit for a top-down game. It’s designed for efficient drawing over long draw distances where you can see a lot of terrain at once. You’re looking straight down at a small patch, so having a terrain that’s a mesh and splitting it into small pieces is likely to be far more efficient.
This, very much.
When playing around with UWP deployment to an Xbox One with a similarish top-down game I found that switching from the standard shader to one that did only what I needed took my game from visibly struggling to a solid 60fps.
Before you do anything, though, connect the profiler and see if you can specifically identify where the time is getting eaten. No point optimising one thing if it’s another that’s dragging you down.
There is a target frame rate setting in Unity which you can set via script, and the quality settings have an option for every other vertical blank, effectively making it 15fps on your device.
But do check out the various other quality settings, as mentioned above. Shadows, lighting, AA and other post-processing are the biggest hits. Anisotropy and texture quality might not cause a noticeable hit to frame rates, but I dunno about low-end ARM devices. Some of them get much slower even when using alpha channels in textures. Camera distance has many different settings - shadows, LODs, terrains etc. can all be set to different maximum (and minimum!) view distances. The less you draw, the faster you go.
As said above, slimmer shaders improve performance a lot too, especially if you weren’t actually using mobile shaders. Anything that improves quality costs performance, so tick and untick check boxes and keep trying on-device builds. Unity’s terrain system in general has been problematic on mobile too. Perhaps decorating a large, flattened cube with meshes would give you better results if you’re not entirely reliant on the way terrain texturing works.
A general optimisation trick you can use to keep the frame rates decent once you have it running OK, is to not use so many Update() methods on scripts. Remove all but one, and have that one method run the rest via delegates. When you use that method you can get to quite a lot of objects before taking a frame rate hit from Update() slowing you down, and it’s easier to wrap your head around than the still experimental ECS and job system.
Profile everything and pay attention to your time spent in code every frame. 1/fps = time you can spend in code every frame. That gives you about 33ms at 30fps, twice that if you skip every other vblank, give or take some overhead.
Can I, to save resources, have a box collider the same aspect ratio, and angle as my camera but slightly wider and slightly higher so it is just out of the viewport and dynamically show and hide content as it enters or leaves the box collider? So just before it is in camera view it loads and just as it leaves the camera view it hides? Or is this bad practice as showing and hiding takes up cpu time in itself?
EDIT: I have come to the realisation that if it is not enable it will not trigger the box collider, derp.
Unity has built in occlusion culling using Umbra. You can use OnBecameVisible or
OnWillRenderObject if you want to only do some stuff in tour code when the entity is visible. Or use the Cullign group API