Skip to content

Commit 3f5f6e6

Browse files
committed
Docs: Manual - improve Instancing documentation
1 parent b64922c commit 3f5f6e6

File tree

4 files changed

+36
-29
lines changed

4 files changed

+36
-29
lines changed

Docs/src/manual.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -937,15 +937,24 @@ When implementing custom animable properties, you have to also implement a numbe
937937

938938
@page Instancing Instancing
939939

940-
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.
940+
Modern graphics cards (GPUs) prefer to receive geometry in large
941+
batches. It is orders of magnitude faster to render 10 batches
942+
of 10,000 triangles than it is to render 10,000 batches of 10
943+
triangles, even though both result in the same number of on-screen
944+
triangles.
941945

942-
OGRE supports a variety of techniques to speed up the rendering of many objects in the Scene.
946+
Therefore it is important when you are rendering a lot of geometry to
947+
batch things up into as few rendering calls as possible.
948+
949+
%Ogre supports a variety of techniques to speed up the rendering of many objects in the Scene.
943950

944951
<dl compact="compact">
945952
<dt>@ref Static-Geometry</dt>
946953
<dd>@copybrief Ogre::StaticGeometry </dd>
947954
<dt>@ref Instance-Manager</dt>
948-
<dd>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.</dd>
955+
<dd>Choose from different algorithms to batch up geometry and still be able to move & animate it. Requires manual setup and the algorithms have some limitations.</dd>
956+
<dt>[Auto-Instancing](@ref Instancing-in-Vertex-Programs)</dt>
957+
<dd>You can advertise instancing in you shaders and Ogre will batch the draw calls for you. Does not support animation.This is less efficient than the Explicit Instance Manager but requires no code changes and can be used with the RTSS.</dd>
949958
</dl>
950959

951960
@tableofcontents
@@ -956,7 +965,7 @@ OGRE supports a variety of techniques to speed up the rendering of many objects
956965

957966
@see [Tutorial - Static Geometry](@ref tut_StaticGeom)
958967

959-
# Instance Manager {#Instance-Manager}
968+
# Explicit Instance Manager {#Instance-Manager}
960969
Instancing is a rendering technique to draw multiple instances of the same mesh using just one render call. There are two kinds of instancing:
961970

962971
@par Software

OgreMain/include/OgreInstanceBatchShader.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ namespace Ogre
3939
* @{
4040
*/
4141

42-
/** This is the same technique the old InstancedGeometry implementation used (with improvements).
43-
Basically it creates a large vertex buffer with many repeating entities, and sends per instance
42+
/** Basically it creates a large vertex buffer with many repeating entities, and sends per instance
4443
data through shader constants. Because SM 2.0 & 3.0 have up to 256 shader constant registers,
4544
this means there can be approx up to 84 instances per batch, assuming they're not skinned
4645
But using shader constants for other stuff (i.e. lighting) also affects negatively this number
@@ -50,7 +49,7 @@ namespace Ogre
5049
(SM 2.0 cards are required) and the same shader can be used for both skeletally animated
5150
normal entities and instanced entities without a single change required.
5251
53-
Unlike the old @c InstancedGeometry implementation, the developer doesn't need to worry about
52+
The developer doesn't need to worry about
5453
reaching the 84 instances limit, the InstanceManager automatically takes care of splitting
5554
and creating new batches. But beware internally, this means less performance improvement.
5655
Another improvement is that vertex buffers are shared between batches, which significantly

OgreMain/include/OgreInstanceManager.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,15 @@ namespace Ogre
4141
* @{
4242
*/
4343

44-
/** This is the main starting point for the new instancing system.
44+
/** This is the main starting point for the manual instancing system.
45+
46+
Instancing allows to save both memory and draw calls. While
47+
StaticGeometry stores 500 times the same object in a batch to display 500
48+
objects, a hardware instancing implementation stores the object once,
49+
and then re-uses the vertex data with different shader parameter.
50+
You can move the batched objects independently of one another which
51+
you cannot do with StaticGeometry.
52+
4553
Each InstanceManager can control one technique and one mesh, but it can manage
4654
multiple materials at the same time.
4755
@ref SceneManager::createInstanceManager, which creates this InstanceManager. Each one

OgreMain/include/OgreStaticGeometry.h

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,15 @@ namespace Ogre {
4242
/** \addtogroup Scene
4343
* @{
4444
*/
45-
/** Pre-transforms and batches up meshes for efficient use as static
45+
/** Pre-transforms and batches up meshes on the CPU for efficient use as static
4646
geometry in a scene.
4747
48-
Modern graphics cards (GPUs) prefer to receive geometry in large
49-
batches. It is orders of magnitude faster to render 10 batches
50-
of 10,000 triangles than it is to render 10,000 batches of 10
51-
triangles, even though both result in the same number of on-screen
52-
triangles.
53-
@par
54-
Therefore it is important when you are rendering a lot of geometry to
55-
batch things up into as few rendering calls as possible. This
56-
class allows you to build a batched object from a series of entities
57-
in order to benefit from this behaviour.
48+
This class allows you to build a batched object from a series of entities.
5849
Batching has implications of it's own though:
59-
@li Batched geometry cannot be subdivided; that means that the whole
50+
- Batched geometry cannot be subdivided; that means that the whole
6051
group will be displayed, or none of it will. This obivously has
6152
culling issues.
62-
@li A single world transform must apply to the entire batch. Therefore
53+
- A single world transform must apply to the entire batch. Therefore
6354
once you have batched things, you can't move them around relative to
6455
each other. That's why this class is most useful when dealing with
6556
static geometry (hence the name). In addition, geometry is
@@ -68,18 +59,18 @@ namespace Ogre {
6859
space than the movable version (which re-uses the same geometry).
6960
So you trade memory and flexibility of movement for pure speed when
7061
using this class.
71-
@li A single material must apply for each batch. In fact this class
62+
- A single material must apply for each batch. In fact this class
7263
allows you to use multiple materials, but you should be aware that
7364
internally this means that there is one batch per material.
7465
Therefore you won't gain as much benefit from the batching if you
7566
use many different materials; try to keep the number down.
76-
@par
67+
7768
In order to retain some sort of culling, this class will batch up
7869
meshes in localised regions. The size and shape of these blocks is
7970
controlled by the SceneManager which constructs this object, since it
8071
makes sense to batch things up in the most appropriate way given the
8172
existing partitioning of the scene.
82-
@par
73+
8374
The LOD settings of both the Mesh and the Materials used in
8475
constructing this static geometry will be respected. This means that
8576
if you use meshes/materials which have LOD, batches in the distance
@@ -91,15 +82,15 @@ namespace Ogre {
9182
not degraded). Be aware that using Mesh LOD in this class will
9283
further increase the memory required. Only generated LOD
9384
is supported for meshes.
94-
@par
85+
9586
There are 2 ways you can add geometry to this class; you can add
9687
Entity objects directly with predetermined positions, scales and
9788
orientations, or you can add an entire SceneNode and it's subtree,
9889
including all the objects attached to it. Once you've added everything
9990
you need to, you have to call build() the fix the geometry in place.
10091
@note
101-
This class is not a replacement for world geometry (@ref
102-
Ogre::SceneManager::setWorldGeometry). The single most efficient way to
92+
This class is not a replacement for world geometry (@ref
93+
Ogre::SceneManager::setWorldGeometry). The single most efficient way to
10394
render large amounts of static geometry is to use a SceneManager which
10495
is specialised for dealing with that particular world structure.
10596
However, this class does provide you with a good 'halfway house'
@@ -527,8 +518,8 @@ namespace Ogre {
527518

528519
public:
529520
/**
530-
You should not construct instances of this class directly; instead, call
531-
SceneManager::createStaticGeometry, which gives the SceneManager the
521+
You should not construct instances of this class directly; instead, call
522+
SceneManager::createStaticGeometry, which gives the SceneManager the
532523
option of providing you with a specialised version of this class if it
533524
wishes, and also handles the memory management for you like other classes.
534525
*/

0 commit comments

Comments
 (0)