FPS is lower with smaller number of vertices and higher with higher number - confused!

Hi,

I am running the following test in Unity:
Render 125000 (yes, 125 thousand ) meshes and render the FPS and triangles on screen. The results are confusing and I would like to know why. If the meshes decrease in size, hence the number of rendered vertices decreases, the FPS drops… Results:
test1:125000 meshes, (size 707070 cubes, random filled with 0.83%) 169.4 million vertices, 10.3 FPS
test2:125000 meshes, (size 777 cubes, random filled with 61.9%), 10.5 million vertices, 3.8 FPS (!)

Then disabling Dynamic and Static batching, I get the same results:
test3:125000 meshes, (size 707070 cubes, random filled with 0.83%) 156.6 million vertices, 10.4 FPS
test4:125000 meshes, (size 777 cubes, random filled with 61.9%), 10.4 million vertices, 4.9 FPS (!)
test5:125000 meshes, (size 333 cubes, ), 2.7 million vertices, 5.0 FPS (!)

To be noted, there is only one graphic object in the whole scene and the meshes are the same mesh, drawn with Graphics.DrawMesh, in a 3d grid.
What is it that I get lower FPS with smaller meshes and fewer stuff drawn on the screen?
2488611--171657--test1.png 2488611--171658--test2.png 2488611--171659--test3.png 2488611--171660--test4.png 2488611--171661--test5.png

And a good question in the end:
Is it good to have a smaller number of meshes filled at max (65534 vertices per mesh) or a larger number and not filled at max? From my test here, the results are very confusing. It would seem that for the same number of meshes, having more vertices, increases the FPS…

Your information does not match the stats you post.
First of all you do not draw 125000 meshes each time. You might draw this number of cubes but the individual meshes (drawcalls) is different. You have ~2500 Batches for your first example. But you have over 100k(insane) Batches you draw in the second example. And the number of Batches equals the number of meshes I assume in your example.

The GPU can handle millions of vertices, but the capacity for drawcalls is limited. If you reach 2000 you should start to optimize your scenes.

1 Like

The code below must render 125000 meshes! That is what I use. Meshes have a size of 70x70x70 but only few cubes (so I don’t hit 65534) vertex limit. For now I fill the meshes with random positioned cubes.
P.S I do not understand why it would produce only around 2500 batches if the mesh size is 70x70x70 and full if the mesh is 7x7x7 . Any ideas?

    void Update()
    {
        for (int x = 0; x < 50; ++x)
        {
            for (int y = 0; y < 50; ++y)
            {
                for (int z = 0; z < 50; ++z)
                {
                    Graphics.DrawMesh(VisualMesh, new Vector3(ChunkWidthX * x, ChunkWidthY * y, ChunkWidthZ * z), Quaternion.identity, material, 0);
                }
            }
        }
    }

Your test has a very bad setup.
First regarding to your issue. If 70 or 7 describes ChunkWidth then you end up that most of your objects are out of your viewport and are culled. 70*50 = 3500 and is behind the maximum default render distance.

Keep consistency in mind. If you want to render different amounts of vertices per object make sure the actual shape of hte object is the same. E.g. use cubes with different subdivisions.

I believe that your script and Graphics.DrawMesh stresses your CPU and that the very low framerate results from this loop. Because rendering 5 million vertices at 2500 Batches should be manageable by a decent systems. Take a look at the Profiler. You can even disable the camera, I believe there wont be a big improvement on the framerate while nothing is rendered.
What you want to do instead is to generate these objects just once using Instantiate or new GameObject.

Also, 125000 Objects is an overkill for whatever you want to test.

1 Like

Thanks for your reply - now you cleared it up for me - I was going over the maximum render distance. I was just testing the limits of Unity with this. Previously I made a Minecraft style game with game objects for each 1616256 chunk. I got a reasonable performance up to 128 render distance. I could play with 256 render distance but the results were not satisfactory. Now I want to do things a bit differently and use no game objects but Graphics.Drawmesh instead + 3d chunks. This way I can simply not render chunks which are either empty or full.
I am hoping that by not using game objects, I can make the game render distance much higher. The Minecraft Windows 10 Edition renders 512 in x,z and 258 on y. It works brilliantly as well. I want to see if I can do also 512 and even higher render distances.