Click or drag to resize
DigitalRuneInstanceData Structure
Describes a custom vertex format that contains instance data for hardware instancing.

Namespace: DigitalRune.Graphics
Assembly: DigitalRune.Graphics (in DigitalRune.Graphics.dll) Version: 1.2.0.0 (1.2.1.14562)
Syntax
[SerializableAttribute]
public struct InstanceData : IVertexType

The InstanceData type exposes the following members.

Constructors
  NameDescription
Public methodInstanceData(Matrix, Vector4)
Initializes a new instance of the InstanceData struct.
Public methodInstanceData(Vector3F, Pose, Vector4F)
Initializes a new instance of the InstanceData struct.
Public methodInstanceData(Vector4, Vector4, Vector4, Vector4)
Initializes a new instance of the InstanceData struct.
Top
Methods
Operators
  NameDescription
Public operatorStatic memberEquality
Compares two objects to determine whether they are the same.
Public operatorStatic memberInequality
Compares two objects to determine whether they are different.
Top
Fields
  NameDescription
Public fieldRegister0
The first instance data register.
Public fieldRegister1
The second instance data register.
Public fieldRegister2
The third instance data register.
Public fieldRegister3
The fourth instance data register.
Public fieldStatic memberVertexDeclaration
The vertex declaration.
Top
Properties
  NameDescription
Public propertyStatic memberSizeInBytes
Gets the size of the InstanceData structure in bytes.
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate propertyIVertexType.VertexDeclaration
Gets the vertex declaration.
Top
Remarks

When hardware instancing is used in the MeshRenderer, the vertex attribute semantic "BLENDWEIGHT" is used to add instance information to each vertex. The instance information is stored in 4 float4 vectors (Register0 to Register3).

By default, the MeshRenderer uses Register0 to Register2 to store the first 3 rows1 of the world matrix. The 4th row is always (0, 0, 0, 1); hence, we can use Register3 to store additional data. The MeshRenderer uses Register3 to store InstanceColor and InstanceAlpha.

1 If the world matrix is stored in a Matrix44F (DigitalRune data type), Register0 to Register2 store the first 3 rows of the world matrix. If we are talking about a world matrix in a Matrix (XNA data type), Register0 to Register2 store the first 3 columns of the world matrix. World matrices in DigitalRune Mathematics and XNA are transposed (see documentation of DigitalRune Mathematics).

The above paragraphs describe how the MeshRenderer and the default DigitalRune material shaders use hardware instancing. However, you can use this vertex structure to store any other form of instance data in 4 float4 vectors. You need to create a special shader which knows how to interpret the data.

See Also