Vertices and performance

I am making a side scrolling shooter, my opening level is set by the coast with mountains in the background. So far the game is running flawlessly on my PC, but when I rendered it and ran it on my less powerful laptop my fps was dropping as low as 16fps. Wherever I used trees the game would drop the fps, so I deleted a lot of the trees but im still having performance issues.

While looking at the statistics in the editor the max verts measured at 2.3 million, and the lowest 200k, the average with no trees and just mountains is around 500k. I read for mobile devices 100k verts is the recommended limit, is this true? If it is I think I have a massive problem on my hands!

Here is a screenshot with the stats window enlarged:

bump

Where did you read this? For mobile - the range of devices and specs are so wide and numerous - I think suggesting 100k verts - is a silly assumption that would only run on a very narrow range of devices. Might be it excludes older devices, or is only targeting the most popular higher end devices. The article you read - should be clear on this suggestion.

What is causing the vertex count spike - the trees?
Is the view you provided going to be the distance the player sees the world - never closer?
The tress look really beautiful. Which means they could be reduced in detail considerably.
Trees have lods - are you using this feature?

Turn off the real-time water reflection and see what the stats of your scene are - does it run as desired?

Optimization is a balancing act. Consider less detail in the trees, less detail in the landscape/terrain, less detail on the ships, and less detailed water with faked reflections.

BTW are you using any image effects? My experience has been that those are often the worst performance hogs. You should just pull out the profiler and see what’s going on (if you are on Unity 5.x).

I read it in one of the Unity documentation pages, this one:

https://docs.unity3d.com/Manual/OptimizingGraphicsPerformance.html

The actual quote is: “Generally speaking, aim for no more than 100,000 vertices on mobile.” Perhaps this article was written a long time ago and hasn’t been updated?

The tress are the main cause of the count spike, it goes from 400k up to 2 million as soon as the trees appear on screen. The view displayed is fixed, the background scrolls from right to left.

I purchased the trees from the asset store, I havent changed any LOD although I messed with the shader and found all the mobile shaders made them look very ugly so left the standard shader enabled (although the tress are very far away so this may not be noticeable…)

I will disable the water reflections too and see what that does to performance.

I’m only running a few image effects, colour correction, anti aliasing, and screen space ambient occlusion. I have fog enabled in the editor settings too.

SSAO is rough…anti-aliasing will certainly slow things down as well. USE THE PROFILER!!! I can’t stress this enough. You’ll know what you have room for when it comes to FX. One technique you can use is to just start stripping the game down to as little as you can, then introduce more FX until you reach your limit.

Oh, and one more thing. When you are checking “frame rate” monitor the milliseconds per frame not the frames per second. Read this article (or just google “frames per second or milliseconds per frame”) to learn why.

http://renderingpipeline.com/2013/02/fps-vs-msecframe/

1 Like

I loaded the profiler up but honestly I didn’t know what to make of what it was showing me:

I managed to find a shader from the mobile section which didnt make the trees look too bad, this dropped the max verts down to 1.5 million. I’ve also baked the water reflections rather than running them in real time.

Regarding milliseconds, from what I can tell it is hovering around 12 - 14ms most of the time, although I see in my profiler pic it spiked above that a few times (I believe 16ms is the magic number to stay under?)

ms / frame = frames / second

60 fps = 16.67 ms

To convert between the two, you can use the formula (that I just made up):

(1 / fps) * 1000 = ms / frame

Learn more about the profiler here and here, but there’s also a “frame debugger” connected with the profiling stuff that is often helpful for graphics. It will break down all of the draw calls and tell you what’s using the most draw calls (which is normally the worst stuff).

2 Likes

Thanks a lot for the info :slight_smile: I have replaced many of the trees with 2D sprites, you cant tell the difference when the game is in motion, but just so I know is there a rough ballpark figure for Vertices on mobile? Because most of the level is still over the 1 million mark due to the mountains and enemy space ships.

I think I read 500,000 for newer mobiles in the unreal manual.

@serbusfish There is no “ballpark vertex count” for mobile devices (although the Unity manual and others may try to say so). The truth of the matter is, some widely used smartphones are faster than some computers (especially low-end laptops). Some computers, like Microsoft’s Surface, are actually tablets with an optional keyboard. So a better question would be about a ballpark vertex count for low-end devices (mobile devices and computers alike). Even that could not really be answered, though, because there are so many different factors: if you optimize in one way, you may be able to handle more vertices. That is why you often find vague answers when it comes to optimization. For more information, I’ll refer you to these posts:

http://answers.unity3d.com/topics/optimization.html?sort=votes&filter=all

Now that you know where I come from, I’ll try to answer your question a bit more directly. In my experience, 1 million vertices is too much to ask for of many mobile devices. That said, there are probably some that can handle it…you should test one a variety of devices and decide on the trade-off between graphical quality and number of target devices. You can search for charts like this that are invaluable in such decision making (this is just an example…it shows OS usage, not hardware, but you get the idea):

3 Likes