The Stats window

Stats Window, which is called Rendering Statistics Window, will Rendering Statistics data in real time.

Time per frame andFPS

Frames per seconds represent the amount of time it takes for the engine to process and render a game frame. This number is influenced by the number of rendered objects in the scene and the performance of the GPU. The higher the FPS, the smoother and smoother the animation will be. Generally speaking, the picture of more than 30FPS will not be felt by the human eye, which has the feature of visual residue. The light stops on the retina and remains for about 1/24 of a second, so the game picture should be at least 30 frames per second. In addition, FPS values in Unity only include updated and rendered frames from the game’s Scene, not scenes edited in the editor and other monitoring window processes.


CPU

Gets the absolute value of the time currently occupied by the CPU for computation, or the point in time at which the CPU time will remain the same if the Unity main process is hung up or hibernated.


Render thread

The amount of time that the GPU rendering process takes to process an image, which is determined by the GPU performance.


Seema’s name is Batched Draw Calls, which is A built-in Draw Call Batching technology in Unity.

Generally speaking, each time the engine conducts a DrawCall for an object, it will generate a Batch, which contains all the mesh and vertex data of the object. When rendering another same object, the engine will directly call the information in the Batch and send relevant vertex data directly to the GPU. In order to make the rendering process more efficient, that is, the Batching technique is to merge all the objects with similar materials.

For objects with multiple Batches of different Shaders and Materials, the rendering process can be time-consuming, as multiple Batches can be created. Each modification of an object’s material or map affects the composition of the Batches data set. Therefore, if there are a large number of objects with different materials in the scene, it will obviously affect the rendering efficiency of GPU. Design-related proposals of a batch:

1. Although Unity engine comes with Draw Call Batching technology, we can also manually merge objects with similar materials; 2. Try not to modify the Scale of an object’s seemsto be Batches, as this will create a new Batch. 3. In order to improve the rendering efficiency of GPU, fewer materials should be used on an object as much as possible to reduce the excessive cost of Batches. 4. For objects that do not move in the scene, consider setting the Static property. Static objects are automatically optimized internally.

SetPass calls

In the unity4. x and 3.x Stats panels, the first item was “Draw calls”. However, in the unity5. x version, the Stats panel has no “Draw calls” and instead has a “SetPass calls”.

For example, if there are 100 GameObjects in the scene, and they all have the same Material, it is very likely that these 100 objects will be combined into one Batch by Unity’s Batching mechanism. So “Batchs” is a poor description of Unity’s rendering performance, it only reflects the number of batched objects in the scene. Draw calls? Again, no. Each “Draw call” is a rendering request sent by CPU to each GPU, which includes all the vertex parameters, triangular surfaces, index values, number of pixels, etc., of the rendering object. This request does not occupy too much small amount, but the real consumption of rendering resources is after the GPU gets the request instruction. The instructions are sent to the Shader of the corresponding object, which reads the instructions and informs the corresponding render channel (Pass) to render. Let’s say you have a gameObject in your scene that you want to look really cool, with a lot of specific Shaders on its Material. In order to achieve this effect, the Shader may contain many passes, and a “SetPass call” is generated whenever the GPU is about to run a Pass, so “SetPass calls” are more convincing in describing the rendering performance overhead.


25 k ∗ n (GHZ) ∗ Percentage/Framerate = Batch/Frame

This is an important index of drawing images, and can be used as the primary reference to measure the efficiency of drawing scenes.

A Draw Call, etc. is equal to one Batch of DrawlndexedPrimitive(DX) or glDrawElements(OGL). NVIDIA has proposed in GDC that 25K Batch/SEC rendering will make the 1GHz CPU reach 100% utilization, so use the formula:

You can calculate how many batches certain cpus can hold. For example, a Redmi phone with a CPU of 1.5Hz wants the game to run 30 frames, assuming 20% of its resources are allocated for rendering. So how many drawcalls can it resist? 25K * 1.5 * 0.2/30 = 250. Therefore, if the CPU does not allocate more resources for rendering computation, there will be less anti-d-man awCall. The Batches you see in the Stats panel are the total Batch of renderings, which is the same as a DrawCall. But you can get the DrawCall before the last batch is processed in Unity. Therefore, we need to be careful not to confuse feelings.


Saved By Batching :

This value is due to Batch reduction of DrawCall, which can indirectly see the effect of scene optimization. This value consists of two parts: Static Batching and Dynamic Batching. While this built-in auto-merge with Unity has its advantages, it’s not without its drawbacks. Static merges incur additional memory and storage overhead, while dynamic merges impose additional CPU overhead. Refer to Unity’s official documentation for this section. In general you want the elements to have the same material. Usually two textures that differ only in texture can be combined into one larger image, which is called a sum image. In addition, when using ShadowCaster, it is possible to merge renderings with different textures as long as the materials are the same.

Dynamic Batches

Dynamic merge amounts that are automatically completed when the following conditions are met:

  • The total number of vertices is less than 900.
  • Mirror transform changes are not included. I don’t change the Scale.
  • If dynamic lightmap is used, specify the correct lightmap.
  • Do not use multi-pass shaders.

Because of the need to convert to world coordinates by CPU calculation at merge time, this technique is only worthwhile if the CPU consumption is “cheaper” than the DrawCall consumption. This metric can vary depending on the platform; for example, if DrawCAll is cheap on The Apple platform, it should not be used. This feature can be turned on and off in Editor – > Project Setting – >Player.



Static Batches

Objects that cannot be moved in a scene can use static merges, which are not limited by the number of vertices and can have significantly fewer drawcalls. But in order to combine elements into a large model, this technique requires extra memory. The main memory cost is that shared polygons are created repeatedly in memory. So sometimes rendering efficiency needs to be sacrificed to avoid static merging to keep memory small. For example, using this technology in dense woods can cause a lot of memory consumption.


Verts

The number of vertices rendered in the camera field of view.

Tis

The total number of triangles rendered in the camera field of view.

What about Tris and Verts

1. The rendering performance of Camera is affected by Draw calls. Rendering an object generates a Draw call, and the time it takes to process a Draw call is determined by the number of Tris and Certs on it. Merging objects as much as possible greatly improves performance. A very simple example is a scenario where there are 1000 different objects, and each object has 10 Tris; There are 10 different objects in Scenario 2, each with 1000 Tris. In rendering processing, 1000 Draw Calls were generated in Scene 1, which was significantly slower than scene 2.

2. Tris and Verts in the Unity stats view are more than just Tris and Tris in the trapezoid of the visual cone, but are Verts and Tris under all values of the Camera field of view, in other words, Even if you don’t see the cube in your current Game view, if you don’t see the Cube when you turn the field of View up to 179, stats won’t count, GPU won’t render, otherwise it will render, and Unity won’t split the model, Unity will render the entire model even if only one vertex needs to be rendered. (Refer to the Unity Camera Component Parameter Description from Mess)

Create an empty scene with no objects added, why is the Status panel showing 1.7K Tris and 5.0K Verts? This is because the empty Scene comes with the default Skybox, Windows — >Lighting open the Scene panel under Ligh and set the material in Skybox to empty. Delete that, and Tris and Verts are going to be zero.

Scree

Gets the resolution size of the current Game screen, followed by a value representing total memory usage.



Shadow casters

Indicates how many objects in the scene can cast shadows. These objects are usually used as light sources in the scene.


Visible skinned meshed

The number of skin meshes rendered.


Animations

The number of animations being played.


In edit mode, the data can be obtained by script, but the package is not very good, the code is as follows:

<span style="color:#000000"><code> GUILayout<span style="color:#009900 ! important">.TextField</span>(<span style="color:#009900 ! important">"Total DrawCall: "</span> + UnityStats<span style="color:#009900 ! important">.drawCalls</span>)<span style="color:#880000 ! important"><em>; </em></span> GUILayout<span style="color:#009900 ! important">.TextField</span>(<span style="color:#009900 ! important">"Batch: "</span> + UnityStats<span style="color:#009900 ! important">.batches</span>)<span style="color:#880000 ! important"><em>; </em></span> GUILayout<span style="color:#009900 ! important">.TextField</span>(<span style="color:#009900 ! important">"Static Batch DC: "</span> + UnityStats<span style="color:#009900 ! important">.staticBatchedDrawCalls</span>)<span style="color:#880000 ! important"><em>; </em></span> GUILayout<span style="color:#009900 ! important">.TextField</span>(<span style="color:#009900 ! important">"Static Batch: "</span> + UnityStats<span style="color:#009900 ! important">.staticBatches</span>)<span style="color:#880000 ! important"><em>; </em></span> GUILayout<span style="color:#009900 ! important">.TextField</span>(<span style="color:#009900 ! important">"DynamicBatch DC: "</span> + UnityStats<span style="color:#009900 ! important">.dynamicBatchedDrawCalls</span>)<span style="color:#880000 ! important"><em>; </em></span> GUILayout<span style="color:#009900 ! important">.TextField</span>(<span style="color:#009900 ! important">"DynamicBatch: "</span> + UnityStats<span style="color:#009900 ! important">.dynamicBatches</span>)<span style="color:#880000 ! important"><em>; </em></span> GUILayout<span style="color:#009900 ! important">.TextField</span>(<span style="color:#009900 ! important">"Tri: "</span> + UnityStats<span style="color:#009900 ! important">.triangles</span>)<span style="color:#880000 ! important"><em>; </em></span> GUILayout<span style="color:#009900 ! important">.TextField</span>(<span style="color:#009900 ! important">"Ver: "</span> + UnityStats<span style="color:#009900 ! important">.vertices</span>)<span style="color:#880000 ! important"><em>; </em></span></code></span>Copy the code

Reference: blog.csdn.net/wdmzjzlym/a…

Blog.csdn.net/fansongy/ar…

Reprint for reference