4.7. I NSTANCING Introduction to geometry instancing.

12
4.7. INSTANCING Introduction to geometry instancing

Transcript of 4.7. I NSTANCING Introduction to geometry instancing.

Page 1: 4.7. I NSTANCING Introduction to geometry instancing.

4.7. INSTANCINGIntroduction to geometry instancing

Page 2: 4.7. I NSTANCING Introduction to geometry instancing.

INSTANCINGIntroduction to geometry instancing

Page 3: 4.7. I NSTANCING Introduction to geometry instancing.

Instancing

Explore the DirectX SDK Instancing sample

Page 4: 4.7. I NSTANCING Introduction to geometry instancing.

Geometry Instancing

Games often have to render many objects of a similar type (perhaps differing only in terms of colour, position, orientation, etc.).

Rendering a large number of objects (each with a limited number of polygons) can stretch modern GPUs, which are not designed to render a small number of polygons thousands of times per frame (the pre-call setups costs very quickly accumulate).

Page 5: 4.7. I NSTANCING Introduction to geometry instancing.

Geometry Instancing

Submitting triangles to the GPU for rendering is a relatively slow operation.

On modern hardware about 30k-120k batches per second is readily attainable. This amounts to 1k-4k batches per frame at 30fps.

Instancing attempts to minimize the number of draw calls, alongside state changes, and render the same triangles multiple times within the same batch in a single call.

Page 6: 4.7. I NSTANCING Introduction to geometry instancing.

Geometry InstancingInstancing requires the vertex and index data to be organised in a particular way so that multiple copies of the mesh can be drawn per batch.

Instancing is best suited to tasks where the model to be instanced is relatively simple (<1000 triangles). For a complex model, instancing will return little, if any, benefit, as the performance bottleneck will become GPU bound.

Page 7: 4.7. I NSTANCING Introduction to geometry instancing.

Geometry Instancing (Hardware instancing)Hardware instancing sends two vertex streams to the GPU. One stream contains the normal vertex data and a second stream holds instance data (position, colour, etc.). The advantage of hardware instancing is that the original mesh need only be sent once to the GPU (saving memory).

Page 8: 4.7. I NSTANCING Introduction to geometry instancing.

Geometry Instancing (Shader instancing)Shader instancing builds a vertex buffer which holds a number of copies of the original mesh. The buffer is then used to draw batches of the original object. Instance data is set within the shader using constants.

The number of objects drawn per batch is constrained by the maximum number that can be stored within the vertex buffer and the number of available shader constants (e.g. 256 for SM2.0)

Page 9: 4.7. I NSTANCING Introduction to geometry instancing.

Instancing

Explore the DirectX SDK DX10

Instancing sample

Page 10: 4.7. I NSTANCING Introduction to geometry instancing.

DIRECTED READINGDirected reading concerning geometry instancing

Directed

reading

Page 11: 4.7. I NSTANCING Introduction to geometry instancing.

Directed reading: Directed

reading

• Read Batch, Batch, Batch: What Does it Really Mean – for information on the importance of batching within games

• Read GPU Gems 2 – Inside Geometry Instancing for more information on instancing

• Read GPU Gems 3 - Animated Crowd Rendering for more information on advanced instancing

Page 12: 4.7. I NSTANCING Introduction to geometry instancing.

Summary

To do:Read the directed

reading

Think if you would like

to consider instancing

within your project

Today we explored:

Different geometry instancing techniques