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.
In the Game tab of the editor you can enable stats, the “Tris” is what you’re looking for:
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.
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.
Hi! If you are interested in how many triangles all meshes had in a frame you can use Triangles Count counter (more details at Unity - Manual: Rendering Profiler module)
If you are targeting Android you can use
Visible Primitives counter (see more details at Performance counters provided by System Metrics Mali package | System Metrics Mali | 1.0.2).
Both data is at per frame granularity.