DX11 Instancing question

Started by
4 comments, last by michaelmk86 10 years, 11 months ago

Hi everyone,

Based on this tutorial: http://www.rastertek.com/dx11tut37.html

can someone point to me some hints on how to pass the rotation of the Instances to the shader?

Advertisement

Replace the instance position inside VertexInputType by a matrix.

You could also use an array of matrices (inside constant buffer) and index it using SV_InstanceID.

this article explains it in more detail.

you mean like that ?


struct VertexInputType
{
    float4 position : POSITION;
    float2 tex : TEXCOORD0;
    matrix instancePosition;
};

and in what way should I modify the D3D11_INPUT_ELEMENT_DESC ?


        polygonLayout[2].SemanticName = "TEXCOORD";
	polygonLayout[2].SemanticIndex = 1;
	polygonLayout[2].Format = DXGI_FORMAT_R32G32B32_FLOAT;
	polygonLayout[2].InputSlot = 1;
	polygonLayout[2].AlignedByteOffset = 0;
	polygonLayout[2].InputSlotClass = D3D11_INPUT_PER_INSTANCE_DATA;
	polygonLayout[2].InstanceDataStepRate = 1;

You will need multiple elements inside the InputLayout describing the matrix (incrementing the SemanticIndex and AlignedByteOffset).

The DirectX SDK (june 2010) has a sample about instancing that uses this method ( inside the Direct3D10 folder, so minor changes might be needed to adapt it to Dx11)

  • looks like passing the rotation with TEXCOORD is not possible.
  • using an array of matrices (inside constant buffer) and index it using SV_InstanceID works with rotation, but it can only pass 1024 matrix meaning i can only have 1024 instances of the same model.
  • looking at the DirectX SDK(Direct3D10 folder, Instancing10) i find that is doing Instancing with this "row_major float4x4 mTransform : mTransform;" but i have idea how to use this in dx11, in order to get Instance with rotation and in large numbers like 10k not just 1024.

any ideals?

bump

This topic is closed to new replies.

Advertisement