Have you found any use for this field in D3D11_INPUT_ELEMENT_DESC? In all examples I could find it's set to zero when instancing is not used and to 1 when it is. That makes sense. I am just wondering if setting this to sth > 1 can be possibly useful for anything?
DX11 InstanceDataStepRate
It can be useful in some effects.
Example:
Drawing a model multiple times at different positions in pairs (each pair with a different tint).
struct VS_IN
{
float3 position;
...
float4x4 instanceWorld : mTransform ;
float4 tint : mTint;
};
Since 2 instances should be draw with the same tint the instance step rate is 2
const D3D11_INPUT_ELEMENT_DESC instlayout[] =
{
...
{ L"mTransform", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
{ L"mTransform", 1, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 16, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
{ L"mTransform", 2, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 32, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
{ L"mTransform", 3, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 48, D3D11_INPUT_PER_INSTANCE_DATA, 1 },
{ L"mTint", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 2, 0, D3D11_INPUT_PER_INSTANCE_DATA, 2 },
};
Most common instancing effects use step rate = 1 though.
I actually came up with a nifty way of using this-- particle LOD. Instead of having one giant honking texture with multiple particles packed onto it (think a cloud of sparks), you can actually create a few (geometrically) distinct particles that are simmed/drawn as one unit. In the vertex shader, you can add some random offsets to each sub-particle and get something visually identical with less fillrate consumption.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement