Search Unity

Doubling the triangles of models?

Discussion in 'Editor & General Support' started by Nexum1, Jun 13, 2012.

  1. Nexum1

    Nexum1

    Joined:
    Sep 16, 2010
    Posts:
    116
    Hi,

    I have a model, that within unity shows that it is 269 triangles when viewing the model in the editor.

    When model is placed in the game screen however it is registered as exactly double that. Are there any solutions or explanations as to what might be causing this?

    Thanks for taking the time to read. :D
     
  2. andorov

    andorov

    Joined:
    Feb 10, 2011
    Posts:
    1,061
    Do you have shadows turned on?
     
  3. Nexum1

    Nexum1

    Joined:
    Sep 16, 2010
    Posts:
    116
    I had "Cast shadows" and "Receive shadows" on.. Switched that off, no result yet. Still double the triangles.

    I have checked the spot and directional lights in my scene, all are set to "no shadows".

    Thanks Andorov :) Anything else you might suggest?
     
  4. Screenhog

    Screenhog

    Joined:
    Jul 2, 2009
    Posts:
    498
    Try changing the material to a VertexLit material.

    When Unity gives you the stats of the number of triangles, it's not giving you the actual number of polygons... it's giving you the number of polygons, with each polygon multiplied by the number of draw calls its takes up. A diffuse material is 2 draw calls. VertexLit is 1 draw call. Some materials have 3 or 4 draw calls.

    While it is inaccurate if you're looking for the true number of polygons, it's a more useful number for actual performance of your scene.
     
    lPVDl likes this.
  5. Nexum1

    Nexum1

    Joined:
    Sep 16, 2010
    Posts:
    116
    Oh! I see, thank you very much. That worked exactly as you explained! It actually makes a lot of sense.. :)
     
  6. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    Something else to take into consideration is that depending on the uv layout of the model there will be extra vertices added for hard edges and seams. There may also be extra vertices added if there is a second uv set for lightmapping.
     
  7. Screenhog

    Screenhog

    Joined:
    Jul 2, 2009
    Posts:
    498
    Extra vertices, yes. However, the addition of extra vertices for hard edges does not affect the number of triangles, which is what he was counting.
     
  8. chronos78

    chronos78

    Joined:
    Dec 6, 2009
    Posts:
    154
    That is true. I was merely pointing out that triangle count isn't the only thing that can be report differently in Unity when compared to a modelling application and some of the reasoning behind it. Thought it might be helpful as it is the next logical place that might cause some confusion when trying to figure out why the numbers don't match.
     
  9. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    No, it is not. Most materials are only one draw call. The more relevant thing is the lighting setup.

    You get extra draw calls for your materials if you have per-pixel spot or point lights affecting them: one draw call per light. This is because Unity renders the object once with vertex lighting + 1 directional light (the 'ForwardBase' pass) and then 'adds on' the extra light from additional per-pixel lights in additional passes (the "ForwardAdd' pass). (This is under Forward Rendering, mind you. Deferred is a whole other bag of rabid cats).

    Using VertexLit reduces draw calls because it forces all lights to be fed in through vertex lighting. However, it's not the only way. Other ways to reduce the GPU workload include:

    • Dropping the Quality Level (or changing the current Quality Level's max pixel light count to be lower)
    • Using a single directional light instead of point/spot lights, e.g. for an outdoor scene
    • Breaking an object up into smaller pieces so that only the parts that are actually touched by the light get redrawn. For example, if your entire level were a single mesh, then every per-pixel light would cause the entire level to be redrawn. If you broke it up so that e.g. each wall is a separate object, then a light shining on a wall will cause only *that wall* to be redrawn, rather than the whole level. This is a balancing act, though, because breaking objects up increases draw calls.
    • Bake static lights into lightmaps. Lightmaps are rendered as part of the ForwardBase pass and so don't invoke any extra draw calls.

    Also, shadow casters have to be rendered 1 extra time per light that they're casting shadows from, and shadow receivers need to be rendered one extra time per light that is casting shadows on them.
     
  10. Screenhog

    Screenhog

    Joined:
    Jul 2, 2009
    Posts:
    498
    Thanks for the correction, Superpig. You're right.
     
  11. Nexum1

    Nexum1

    Joined:
    Sep 16, 2010
    Posts:
    116
    Thank you very much guys, very informative! :)
     
  12. eppspqgu

    eppspqgu

    Joined:
    Jun 15, 2012
    Posts:
    3
    thank you very much.