OGRE 14.3
Object-Oriented Graphics Rendering Engine
Loading...
Searching...
No Matches
Instancing

Instancing significantly reduces the CPU overhead of submitting many separate draw calls and is a great technique for rendering trees, rocks, grass, RTS units and other groups of similar (but necessarily identical) objects.

OGRE supports a variety of techniques to speed up the rendering of many objects in the Scene.

Static Geometry
Pre-transforms and batches up meshes for efficient use as static geometry in a scene.
Instance Manager
Instancing is a way of batching up geometry into a much more efficient form, but with some limitations, and still be able to move & animate it.

Static Geometry

Modern graphics cards (GPUs) prefer to receive geometry in large batches. It is orders of magnitude faster to render 10 batches of 10,000 triangles than it is to render 10,000 batches of 10 triangles, even though both result in the same number of on-screen triangles.

Therefore it is important when you are rendering a lot of geometry to batch things up into as few rendering calls as possible. This class allows you to build a batched object from a series of entities in order to benefit from this behaviour. Batching has implications of it's own though:

  • A geometry region cannot be subdivided; that means that the whole group will be displayed, or none of it will. This obivously has culling issues.
  • A single world transform must apply to the entire batch. Therefore once you have batched things, you can't move them around relative to each other. That's why this class is most useful when dealing with static geometry (hence the name). In addition, geometry is effectively duplicated, so if you add 3 entities based on the same mesh in different positions, they will use 3 times the geometry space than the movable version (which re-uses the same geometry). So you trade memory and flexibility of movement for pure speed when using this class.
  • A single material must apply for each batch. In fact this class allows you to use multiple materials, but you should be aware that internally this means that there is one batch per material. Therefore you won't gain as much benefit from the batching if you use many different materials; try to keep the number down.
See also
Ogre::StaticGeometry
Tutorial - Static Geometry

Instance Manager

Instancing is a rendering technique to draw multiple instances of the same mesh using just one render call. There are two kinds of instancing:

Software
Two larges vertex & index buffers are created and the mesh vertices/indices are duplicated N number of times. When rendering, invisible instances receive a transform matrix filled with 0s. This technique can take a lot of VRAM and has limited culling capabilities.
Hardware
The hardware supports an extra param which allows Ogre to tell the GPU to repeat the drawing of vertices N number of times; thus taking considerably less VRAM. Because N can be controlled at runtime, individual instances can be culled before sending the data to the GPU. Hardware techniques are almost always superior to Software techniques, but Software are more compatible, where as Hardware techniques require D3D9 or GL3, and is not supported in GLES2

All instancing techniques require shaders. It is possible to have the RTSS (Realtime Shader System) generate the shaders for you.

See also
Ogre::InstanceManager
Instancing User-Guide

Static Geometry vs Instancing

Static Geometry Instancing
Any sort of mesh is grouped in a minimal number of meshes, and cannot be updated (each mesh cannot move independently, only all the static geometry would be able to do so.) The same mesh used many times, so Instanced geometry can be updated (each mesh can move independently)
You have a scene with many unique meshes Reuse the same mesh many times without the draw call cost.
Batches up small static detail fragments like grass without shaders. One mesh is repeated many times without the performance hit of having them as individual meshes.
Geometry that doesn't move and has low in GPU requirements Dynamic geometry (animated or moving) and better GPU (sm2.0+)
Batches separate sets of polygons together, as long as they have the same properties such as material. These batches are then automatically split into regions for better culling. You can control the region size. This is a good way to reduce batches for static elements. Good for large numbers of the same exact object. You can have multiple instances of one object that can dynamically move but that are drawn in one draw call.