Unity3d Development (11) editor Drawcall parameter resolution

Source: Internet
Author: User

For the Unity run scenario, there are many parameters that can mark the condition of the scene. This article focuses on the meaning of these parameters, which, if any, is welcome.

Game Stats

Click to 游戏Tab Stats expand the following interface, you can easily see the game running status.

FPS & Time per frame

FPS is usually said to be the frame rate. Each frame time refers to when the render frame needs to be consumed, and this value contains only the times that the game view is updated per frame, and is not affected by other features in the editor, such as profiler. FPS is the inverse of this number. It is worth noting that this value is higher than the frame rate we usually say because we are directly calculating the time difference between two frames. I guess the difference between the two values will be smaller when the phone is packaged, but it won't be the same.

Batches & Drawcall

This is an important indicator of drawing images, which can be used as a primary reference for measuring the efficiency of scene rendering.

A Draw call, which is equal to calling once DrawIndexedPrimitive (DX) or gldrawelements (OGL), equals one Batch.

NVIDIA has proposed 25k batch/sec rendering on GDC to make 1GHz CPU usage 100%, so use the formula

-K ? n ( g h z ) ?P eRCeNTag e/F RameRaTe=BaTCh/F Rame

You can figure out how many batch the CPU can resist. For example, Red Rice Mobile CPU 1.5GHz, assume that 20% resources for rendering, I hope the game ran to 30 frames. How many drawcall can you resist? 25k * 1.5 * 0.2/30 = 250. Therefore, it can be seen from this aspect that if the CPU can not separate more resources for rendering calculation, the drawcall of the anti-resistance will become less.

The batches that you see in the stats panel is the total batch that is rendered equal to Drawcall. But unity can get drawcall before the batch is processed. So be careful not to confuse concepts.

Saved by batching

This value is due to the drawcall of batch reduction, which can indirectly see the effect of scene optimization. This value consists of two parts: Static Batching and Dynamic Batching . This automatic merge built by unity is a lot of advantages, but it's not without flaws. Static merging raises additional overhead for memory and storage, and dynamic consolidation increases the burden on the CPU. This section refers to the official unity document

In general, the elements that you want batch rendering to have the same material. Usually two materials if only the map is different, you can merge the map into a larger image, which is called the graph. In addition ShadowCaster , as long as the material is the same, the rendering can be combined even if the map is different.

Dynamic Batches

Dynamic merging is done automatically when the following conditions are true:

    • The total number of vertices in the model is less than 900.
    • Does not contain mirror transform changes. Do not change scale.
    • If you use dynamic lightmap you need to specify the correct.
    • Do not use multi-pass shader.

Because of the need to turn to world coordinates by CPU computing when merging, this technique is only worthwhile when CPU consumption is "cheaper" than Drawcall. This measure will be based on platform differences, such as the Drawcall on the Apple platform is cheap, should not use this technology. This feature can be Editor set to on Project Setting Player and off in.

Static Batches

Objects that cannot be moved in a scene can use static merges, which are not constrained by the number of vertices, and can significantly reduce drawcall. But in order to merge elements into a large model, this technique requires additional memory. The primary memory consumption is that shared polygons are created repeatedly in memory. Therefore, it is sometimes necessary to sacrifice rendering efficiency to avoid static merging to ensure that memory is small enough. For example, using this technique in dense forests can result in a lot of memory consumption.

Tris & Verts

All triangles and vertices under the camera are also major bottlenecks on low-end hardware.

The script gets the value

Other data for the time being not concerned about, it is necessary to write a single article later. In edit mode, this data can be obtained through scripting, but it is not a good way to make a package. Simply write a little bit, the effect is as follows:

All of the cubes use a static merge, and the patches use dynamic merging. The scene UI has a total of 17 batch. Dynamic batches of 1, static batches of 2 (do not know the split rule), batch rendering of total 20. Each dynamic object 1 Drawcall, a total of 20, 4 dynamic objects 1 drawcall,17 UI generated Drawcall, a total of 38.

The relevant code is as follows:

Using Unityengine;Using System. Collections;Using Unityeditor;public class Testdc:monobehaviour {#region Unity Messagesvoid Ongui () {guilayout. TextField("Total Drawcall:"+ unitystats. Drawcalls);Guilayout. TextField("Batch:"+ unitystats. Batches);Guilayout. TextField("Static Batch DC:"+ unitystats. Staticbatcheddrawcalls);Guilayout. TextField("Static Batch:"+ unitystats. Staticbatches);Guilayout. TextField("Dynamicbatch DC:"+ unitystats. Dynamicbatcheddrawcalls);Guilayout. TextField("Dynamicbatch:"+ unitystats. Dynamicbatches);Guilayout. TextField("Tri:"+ unitystats. Triangles);Guilayout. TextField("Ver:"+ unitystats. Vertices);}#endregion}

Unity3d Development (11) editor Drawcall parameter resolution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.