Jump to content

  • Log In with Google      Sign In   
  • Create Account

DX11 Instancing question


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 michaelmk86   Members   -  Reputation: 189

Like
0Likes
Like

Posted 05 May 2013 - 01:38 PM

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?



Sponsor:

#2 Yourself   Crossbones+   -  Reputation: 1133

Like
0Likes
Like

Posted 06 May 2013 - 01:48 AM

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.



#3 michaelmk86   Members   -  Reputation: 189

Like
0Likes
Like

Posted 06 May 2013 - 06:43 AM

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;

 



#4 Yourself   Crossbones+   -  Reputation: 1133

Like
0Likes
Like

Posted 06 May 2013 - 06:59 AM

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)



#5 michaelmk86   Members   -  Reputation: 189

Like
0Likes
Like

Posted 06 May 2013 - 10:12 AM

  • 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?


Edited by michaelmk86, 11 May 2013 - 02:30 PM.


#6 michaelmk86   Members   -  Reputation: 189

Like
0Likes
Like

Posted 11 May 2013 - 02:35 PM

bump






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS