Instancing rendering Overview

Source: Internet
Author: User
Instancing Rendering

When rendering small objects with few duplicate vertices, using the instancing rendering method can greatly reduce the call to the rendering function, thus improving the efficiency. This method is described in detail in the sample of GPU gems2 and DX9 SDK.

In GPU gems2, The instancing rendering technology is divided into four types:

LStatic batch

LDynamic batch

LVertex constant instantiation

LAPI batch of ry instances

The article describes the technology in Section 4 clearly. The following describes only the three methods in the samples in the dx sdk.

Stream instancing

Stream instancingUse two VB buffers and one IB. A vertex that stores data and an attribute that stores all instances. To draw 1000CubeFor example, a VB Database stores 24 vertices (6 faces, 4 vertices for each surface) and an IB database stores 36 indexes (6 faces, 2 triangles for each surface, 3 vertices for each triangle ). Another VB stores instance data of all 1000 cubes, including color, position, and azimuth.

After each buffer is set, rendering can be performed. Only one cube can be rendered at a time. Before each drawindexedprimitive operation, you must call setstreamsource to set the offset of the instance in the second VB. Obviously, the method of calling drawindexedprimitive for each object must have a great impact on efficiency.

This method is a relatively static method, but it is not the same as the static method in GPU gems2. Static Methods in GPU gems2 only use a large VB and a large Ib. This VB stores the converted geometric instance information, and IB stores the indexes of each instance, then draw all the ry using a drawindexedprimitive. This method requires a large amount of storage and does not support skeleton operations, which consumes a lot of CPU.

Shader instancing

Shader instancing requires a large VB and a large IB to accommodate the vertices and indexes of all instances. In addition, all information about the ry instance is stored in the system memory. Unlike the previous method, you do not need to lock the information of the ry instance to VB when creating VB, but pass it through vertex constants during rendering. Due to the limited number of vertex constants, a batch of geometries may need to be rendered several times before they can be completely completed.

This method is similar to the method for instantiating vertex constants in GPU gems2. However, because this method in GPU gems2 uses all vertex constants for the instancing operation, it cannot perform the skeleton operation. To solve this problem, all vertex constants are not used in the samples in the dx sdk.

HW instancing

This method is strongly recommended in the dx sdk, but the hardware must support vs3_0. The preceding two methods only require hardware support for vs1_1.

The HW instancing method is the same as the stream instancing method mentioned earlier. The difference is that HW instancing uses the API setstreamsourcefreq () provided by dx sdk (). Through this API, you do not need to specify the offset of the instance in VB during rendering, so this method can automatically use oneDrawindexedprimitive is drawn.


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.