Search Unity

Unity inflates the polygon count of objects

Discussion in 'General Graphics' started by ekergraphics, Mar 22, 2018.

  1. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
    We run a very high polygon count scenes, but I'm baffled as to why Unity inflates these numbers even higher.

    To test this, I created an empty project and imported only a single file, and the results are indeed inflated even then:


    A total of around 16k triangles, yet Unity statistics show 60k+.

    In our 4 million polygon project, the numbers are at times up to 13 million in that same window.


    Note that Blender's count is actually slightly different (ignore the weird scaling issue... it's a Max to FBX thing).

    Here's the individual mesh infos:



    Which sums up to about 14k triangles which is actually also a bit lower...

    Apart from me perhaps being very bad at math, what is going on here?
     
  2. N00MKRAD

    N00MKRAD

    Joined:
    Dec 31, 2013
    Posts:
    210
    Well, one thing is that the skybox is actually a sphere and has a few thousand polys.

    Also, I'm pretty sure lighting/shadowmapping inflates polycount.
     
  3. Sepica

    Sepica

    Joined:
    Feb 4, 2014
    Posts:
    6
    True, as well as adding multiple UV channels, they add up as well.
     
  4. ekergraphics

    ekergraphics

    Joined:
    Feb 22, 2017
    Posts:
    257
    That's interesting, I wasn't aware of either case.

    Thank you for the information!
     
  5. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,790
    Also every hard edge will be double the vertex count.
    Example - If there are 2 triangles sharing one edge with different smoothing on each triangle instead of 4 vertices for the two triangles, the count will be 6, 3 vertices per triangle.
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    This has no effect on polycount. You're probably thinking about increased vertex counts, but multiple UV channels may not increase this either if all of the UVs have similar seams to the first.

    Ultimately it comes down to Unity does multiple passes if the scene and it's counting the tris for all of the passes. For the default scene in Unity it's doing one pass for a depth texture, up to four passes for directional light shadow cascades, and one pass for the final render. That's possibly 3x~6x the mesh's polycount depending on how many cascades your meshes get rendered into, plus the skybox.
     
    theANMATOR2b likes this.
  7. tucaz85710

    tucaz85710

    Joined:
    Jan 8, 2018
    Posts:
    14
    Take a plain cube in Blender and save it in the Unity assets folder. Unity converts the mesh to triangles internally. In Blender the cube has 8 verts but in Unity it has 24. It may be due to the conversion process.
     
  8. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Blender is lying.

    Or rather, what Blender (and most 3d modelling tools) calls a vertex and what all GPUs call a vertex are subtly different things.

    A vertex on a GPU is a single set of data with a single position, and a single, constant (per vertex, per mesh) amount of data attached. Basically, a single position, color, normal, and a single coordinate in each of some constant number of UV sets.

    A vertex in Blender is a single position with a variable (per vertex) amount of data attached. It can be a single shared normal, uv coordinate, and color, or unique values for each face attached.

    But a GPU can't deal with a mesh that has vertices with variable amounts of data. GPUs assume a single set of data for each vertex, so they have to be split up if any single bit of data is not identical for all attached faces. I suspect when Blender renders using Cycles' GPU path it has to split up the vertices like this, and it definitely has to for Eevee.
     
    arkano22 and NicolasDuboc like this.
  9. SparrowGS

    SparrowGS

    Joined:
    Apr 6, 2017
    Posts:
    2,536
    I think it also counts drawing the editor, don't know if it effects polycount but iirc the draw call shows the editor overhead too