ModelInstance
Description
Describes a single instance when using geometry instancing.
The layout for GPU instance buffers is defined by Format and the WriteInstance can be used to output instance data in that format.
- See also
Public / Constants
Format
The vertex elements to use for instance buffers.
The vertex buffer layout for instance data is defined as follows:
@0 : Float x 3 (Position) @12 : Float x 3 (Tangent) @24 : Float x 3 (Tangent) @36 : UInt8_Norm_Srgb x 4 (Color) @40 : Float x 1 (TextureCoords) @44 : Float x 1 (TextureCoords) @48 : - end -
To write instance data, use the WriteInstance method.
Public / Constructors
ModelInstance
2 overloads
Creates a new instance of ModelInstance.
Creates a new instance of ModelInstance.
Public / Methods
WriteInstance
Writes instance data to the given buffer.
This method will write a full instance, according to Format, including padding for alignment. The instance elements have the same order as the parameters of this method and are applied during rendering as follows:
-
scale
The vertices in model-space are scaled by the given scale opt factor. -
rotation
A 3x3 orthonormal rotation matrix is applied to the scaled vertices in model-space, where the row vectors given bytangentXYZ
,normalXYZ
andcross(tangentXYZ,normalXYZ)
. -
position
The rotated model-space vertices are translated by the givenposition
offsets, before (if intensity opt is negative) or after (if intensity opt is positive) transforming them from model-space to world-space. -
color
After applying ModelPartFlags.VertexAlphaIsOcclusion and ModelPartFlags.VertexColorIsBaseColor, the vertex color is modulated with the given color opt factor (all channels). Then, the color channels are scaled by the given intensity opt factor, to produce high-dynamic range colors.
- See also
Public / Attributes
Intensity
The high-dynamic range scale for Color (absolute value) and interpretation of Position (value sign).
The default value is 1
.
- See also