Instancing

advertisement
4.7. INSTANCING
Introduction to geometry instancing
Introduction to geometry instancing
Instancing
Explore the DirectX SDK Instancing sample
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).
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.
Geometry Instancing
Instancing 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.
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).
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)
Instancing
Explore the DirectX SDK
DX10 Instancing sample
Directed reading concerning geometry instancing
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
Summary
Today we
explored:
 Different
geometry
instancing
techniques
Download