Search Unity

Question How many triangles displayed?

Discussion in 'Testing & Automation' started by Gandi, Sep 23, 2022.

  1. Gandi

    Gandi

    Joined:
    Aug 17, 2012
    Posts:
    7
    Hello,
    Is it possible to get via code the number of triangles displayed?
    If so, is it possible to include the number of triangles tessellated via shaders with a tessellation pass.
    Thank you for your help.
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,887
    In the Game tab of the editor you can enable stats, the "Tris" is what you're looking for:
    upload_2022-9-23_10-34-37.png

    The profiler may be able to give you more insights.

    I'm not aware of any code API.
    For tessellation, you could simply calculate an approximation knowing the triangles of the input mesh and the tessellation settings.

    Now, on the off-chance that you need to know about this solely because of estimating performance, you should profile and nothing else. Knowing the triangle count is practically useless because the performance of rendering a triangle depends on the material and shader of the mesh. In a time before shaders (ie Quake) it made sense to count triangles of meshes as the single most relevant performance metric - but not anymore in the past ~15 years or so.
     
  3. Gandi

    Gandi

    Joined:
    Aug 17, 2012
    Posts:
    7
    Thank you.
    In my case, the tessalation shader varies according to distance and according to a data layer that indicates whether a texel should be subdivided or not.
    I wanted to measure the amount of polygons that this shader generates. I can of course extrapolate this via the FPS by making a rule of proportion on the difference of the number of polygons without the shader and with the shader.
    This is more complicated but doable.
     
    Last edited: Sep 23, 2022
  4. alexeyzakharov

    alexeyzakharov

    Joined:
    Jul 2, 2014
    Posts:
    507