InstanceData Structure |
Namespace: DigitalRune.Graphics
The InstanceData type exposes the following members.
Name | Description | |
---|---|---|
InstanceData(Matrix, Vector4) |
Initializes a new instance of the InstanceData struct.
| |
InstanceData(Vector3F, Pose, Vector4F) |
Initializes a new instance of the InstanceData struct.
| |
InstanceData(Vector4, Vector4, Vector4, Vector4) |
Initializes a new instance of the InstanceData struct.
|
Name | Description | |
---|---|---|
Equals |
Indicates whether this instance and a specified object are equal.
(Overrides ValueTypeEquals(Object).) | |
GetHashCode |
Returns the hash code for this instance.
(Overrides ValueTypeGetHashCode.) | |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
ToString |
Retrieves a string representation of this object.
(Overrides ValueTypeToString.) |
Name | Description | |
---|---|---|
Equality |
Compares two objects to determine whether they are the same.
| |
Inequality |
Compares two objects to determine whether they are different.
|
Name | Description | |
---|---|---|
Register0 |
The first instance data register.
| |
Register1 |
The second instance data register.
| |
Register2 |
The third instance data register.
| |
Register3 |
The fourth instance data register.
| |
VertexDeclaration |
The vertex declaration.
|
Name | Description | |
---|---|---|
SizeInBytes |
Gets the size of the InstanceData structure in bytes.
|
Name | Description | |
---|---|---|
IVertexType.VertexDeclaration |
Gets the vertex declaration.
|
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.