Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity3d makes 5 times more triangles.

Discussion in 'General Graphics' started by tr1te, Apr 22, 2015.

  1. tr1te

    tr1te

    Joined:
    Sep 5, 2012
    Posts:
    38
    I created an empty project. Nothing changed on it. View scenes statistics and see what it wrote 1.7k triangles in an empty scene.

    Then I add a box with 1.2k triangles. And see what he wrote me 7.7k triangles in the scene. Not difficult to calc that it add 6k triangles, which is 5 times more than the original box.

    Why?

     
  2. colin299

    colin299

    Joined:
    Sep 2, 2013
    Posts:
    176
    if you replace the cube's material to Unlit/texture shader,
    will it become normal again?
     
  3. tr1te

    tr1te

    Joined:
    Sep 5, 2012
    Posts:
    38
    Yeah. But why shader add more triangles?
     
  4. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    421
    the reason why triangles are multiplied on scene because data like UV, Normal, Tangen is actually stored on each vertices, not in every triangles like other Mesh editor does.
    the vertices should be split up so there is no meshes data are removed.

    this is why standard box mesh can have 24 vertices instead of 8
     
  5. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    421
    sorry, i didn't see that, you're asking about triangles, not vertices.

    but you should see "setPass Call", it returns 7 on 7.7k triangles. and batches are increased too.
     
  6. mholub

    mholub

    Joined:
    Oct 3, 2012
    Posts:
    123
    Because every pass counts as additional triangles count.
    Additional paths are because of Directional light shadows.
    Open Window/Frame Debugger and you will see it. Or try to turn off Directional Light shadows and you will see 2 passes (1 for skybox and 1 for cube which is expected)
     
  7. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    2,005
    This is only true when a vertex doesn't share the same uv, normal, tangents etc, otherwise every mesh in Unity would be three time the number of vertices. This is true for a box because normally you'd want hard edges, so each vertex is going to have different normals anyway, but is obviously not true for say a plane ( Unity's plane is 11x11 vertices).


    The 1.7k triangles you see initially is because you are using the new Unity 5.0 skybox. If you go to your main camera and set it to 'Solid Color' (then click in game window) you'll see those 1.7k triangles drop to just 2. I believe the 2 triangles are likely due to how Unity clears the gpu buffers, rendering a fullscreen quad.

    As for additional triangles, every pass in Unity will draw the model again. A shader can have multiple passes, shadow casting requires another pass and in forward rendering each light is an additional pass, deferred is slightly different, but same principles.

    If you want to get a better idea of what is going on behind the scenes check out the new Frame Debugger ( under windows menu) and step through the scene.
     
    FariAnderson and 40detectives like this.
  8. tr1te

    tr1te

    Joined:
    Sep 5, 2012
    Posts:
    38
    Thx a lot!