2.6
Instances

- 2.6.1. Overview
- 2.6.2. Single
- 2.6.3. Batched
- 2.6.4. Billboarded
- 2.6.5. Types

2.6.1
Overview
1
An instance is a renderable object. There are several types of instances available in the r2 package: single, batched, and billboarded.
2.6.2
Single
1
A single instance is the simplest type of instance available in the r2 package. A single instance is simply a pair (m, t), where m is a mesh, and t is a transform capable of transforming the object space coordinates of the vertices contained within m to world space.
2.6.3
Batched
1
A batched instance represents a group of (identical) renderable objects. The reason for the existence of batched instances is simple efficiency: On modern rendering hardware, rendering n single instances means submitting n draw calls to the GPU. As n becomes increasingly large, the overhead of the large number of draw calls becomes a bottleneck for rendering performance. A batched instance of size m allows for rendering a given mesh m times in a single draw call.
2
A batched instance of size n is a 3-tuple (m, b, t), where m is a mesh, b is a buffer of n 4x4 matrices allocated on the GPU, and t is an array of n transforms allocated on the CPU. For each i where 0 <= i < n, b[i] is the 4x4 model matrix produced from t[i]. The contents of b are typically recalculated and uploaded to the GPU once per rendering frame.
2.6.4
Billboarded
1
A billboarded instance is a further specialization of batched instances. Billboarding is the name given to a rendering technique where instead of rendering full 3D objects, simple 2D images of those objects are rendered instead using flat rectangles that are arranged such that they are always facing directly towards the observer.
2.6.4.2 Billboarded Render
2.6.4.3 Billboarded Wireframe
2.6.4.4 Billboarded Wireframe (Side)
5
A billboarded instance of size n is a pair (m, p), where m is a mesh [13], and p is a buffer of n world space positions allocated on the GPU.
2.6.5
Types
1
In the r2 package, instances are instances of R2InstanceType.

[13]
Typically a simple two-polygon unit quad.