Jump to content
  • Advertisement
Sign in to follow this  
simpler

DX11 Problem sending vertex data to shader

This topic is 2121 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

For some reason the vertex data wont be transfered correctly from the vertex buffer to the vertex shader.

This is the c++ vertex structure:


//! Vertex with skinning info.
struct SkinnedVertex
{
XMFLOAT3 Pos;
XMFLOAT3 Normal;
XMFLOAT2 Tex;
XMFLOAT4 Tangent;
XMFLOAT3 Weights;
BYTE BoneIndices[4];
};


This is the HLSL structure:


//! Input vertex data.
struct SkinnedVertexIn
{
float3 PosL : POSITION;
float3 NormalL : NORMAL;
float2 Tex : TEXCOORD;
float4 TangentL : TANGENT;
float3 Weights : WEIGHTS;
uint4 BoneIndices : BONEINDICES;
};


And this is the input layout:


// Create the vertex input layout.
D3D11_INPUT_ELEMENT_DESC vertexDesc[6] =
{
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"TANGENT", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 32, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"WEIGHTS", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 48, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"BONEINDICES", 0, DXGI_FORMAT_R8G8B8A8_UINT, 0, 60, D3D11_INPUT_PER_VERTEX_DATA, 0}
};
// Create the input layout.
D3DX11_PASS_DESC passDesc;
mTech->GetPassByIndex(0)->GetDesc(&passDesc);
HR(gGame->GetD3D()->GetDevice()->CreateInputLayout(vertexDesc, 6, passDesc.pIAInputSignature,
passDesc.IAInputSignatureSize, &mInputLayout));


This is what it looks like in PIX:

uRMgb.png

As you can see the position, normal, texcoord and tangent are transfered correctly. But the weights and bone indices are totally wrong. I have no idea why and I have realised I won't be able to solve this on my own, I really appreciate any help. Also, it seems kinda weird that the tangent is shown as a float3 in PIX when it's acctually a float4.

If you need more information in order to help let me know. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
I didn't know that. What format should I use instead? But I don't understand how that can affect and make the weights data wrong as well. Perhaps you can explain? Edited by simpler

Share this post


Link to post
Share on other sites
DXGI_FORMAT_R8G8B8A8_UINT is not equal to uint4.[/quote]

Strange, I use exactly the same setup and it works for me. Except for the weights I use just one dword, since the values are between 0..1 and 8-bit accuracy is enough.

I use DXGI_FORMAT_R8G8B8A8_UINT in the input layout and uint4 in the hlsl vertex structure.
Otherwise, I store the bone indices in a dword but that's same as 4 bytes.

You can use D3D11_APPEND_ALIGNED_ELEMENT instead of calculating the offsets yourself.

Cheers! Edited by kauna

Share this post


Link to post
Share on other sites

DXGI_FORMAT_R8G8B8A8_UINT is not equal to uint4.


That's not true. The UINT suffix specifies that each component should be interpreted as an 8-bit unsigned integer, and there are 4 values so uint4 is the appropriate type to use in this case.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!