A memory slot for per instance data in a Shader.
These slots are fed within a Shader, and offer the capabilities of feeding per instance data to a Program.
| void nkGraphics::ShaderInstanceMemorySlot::setAsWorldMatrix |
( |
| ) |
|
Prepare the slot to feed world matrices.
This adds a WORLD_MATRIX attribute within the declaration of mesh data. In HLSL, for instance, data can then be accessed like such :
struct VertexInput
{
float4 position : POSITION ;
float4x4 world : WORLD_MATRIX ;
} ;
The matrix is provided as row-major, meaning they can be used like :
float4x4 mvp = mul(projection, mul(view, world)) ;
| void nkGraphics::ShaderInstanceMemorySlot::setAsWorldMatrixInverse |
( |
| ) |
|
Prepare the slot to feed inverse world matrices.
This adds a WORLD_MATRIX_INVERSE attribute within the declaration of mesh data. In HLSL, for instance, data can then be accessed like such :
struct VertexInput
{
float4 position : POSITION ;
float4x4 worldInverse : WORLD_MATRIX_INVERSE ;
} ;
The matrix is provided as row-major, meaning they can be used like :
float4x4 mvp = mul(projection, mul(view, world)) ;
| void nkGraphics::ShaderInstanceMemorySlot::setAsWorldMatrixInvTranspose |
( |
| ) |
|
Prepare the slot to feed world matrices, inversed and transposed.
This adds a WORLD_MATRIX_INVERSE_TRANSPOSE attribute within the declaration of mesh data. In HLSL, for instance, data can then be access like such :
struct VertexInput
{
float4 position : POSITION ;
float4x4 worldInvTranspose : WORLD_MATRIX_INVERSE_TRANSPOSE ;
} ;
The matrix is provided as row-major, meaning they can be used like :
float4 inv = mul(worldInvTranspose, vec) ;
This matrix can be useful to work with normals.