The Unity object's relationship to draw calls

Source: Internet
Author: User

What is Draw Calls?

First, let's look at what is called "Draw Calls": A draw call, which is equal to calling a drawindexedprimitive (DX) or gldrawelements (OGL), equals a Batch.

People who have touched DirectX or OpenGL, the API for drawindexedprimitive and gldrawelements must be familiar. When we prepare the data (usually the vertex information of the triangle) for the GPU to draw out, we must call this function. In other words, if there is a "wooden" chair and an "iron" table on the screen, there will theoretically be two Draw call.

Have you seen special points out of "wood" and "iron"? This means that two objects are using different material balls or different Shader. In DirectX or OpenGL, you will need to call two draw calls if you specify different textures or different Shader descriptions for different objects. Procedure code is as follows:

Setshader ("diffuse"); SetTexture ("Iron");D rawprimitive (Deskvertexbuffer); Setshader ("Vertexlight"); SetTexture ("Wood");D rawprimitive (Chairvertexbuffer);

Every time the change of the Shader or the texture changes, basically is the Rendering Pipeline settings to do the modification, so need different draw call to complete the object drawing. Now that you know why the official files of Unity always want you to use the same material as much as possible to reduce the number of Draw call!

The relationship between the object the camera sees and the draw calls value:

Phenomenon One: So objects are visible, all within the camera range.

Draw calls:27

Phenomenon two: The rear sphere is blocked.

Draw calls is still 27, other values have not changed.

Phenomenon Three: Moving an object [cylinder] to the outside of the camera, the end of the invisible.

This time the draw Calls is less than 2, that is, when an object is not within the camera range, no draw Calls will be generated, that is, the GPU will not draw this item.

Phenomenon three: Behind the blocked ball shielding, not displayed;

This time draw calls is 20

Data comparison:

Summarize:

We want to reduce draw calls can do the following points:

1, when adjusting the camera's access range;

2, the masking of some of the items to be shielded, do not display;

The Unity object's relationship to draw calls

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.