• Create Account

Problem sending vertex data to shader

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.

4 replies to this topic

#1simpler  Members

927
Like
1Likes
Like

Posted 23 September 2012 - 05:28 PM

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:

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!

#2Nik02  Members

4072
Like
1Likes
Like

Posted 24 September 2012 - 12:56 AM

DXGI_FORMAT_R8G8B8A8_UINT is not equal to uint4.

Niko Suni

#3simpler  Members

927
Like
0Likes
Like

Posted 25 September 2012 - 11:42 AM

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, 25 September 2012 - 11:42 AM.

#4kauna  Members

2918
Like
1Likes
Like

Posted 25 September 2012 - 02:40 PM

DXGI_FORMAT_R8G8B8A8_UINT is not equal to uint4.

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, 25 September 2012 - 06:15 PM.

#5MJP  Moderators

18194
Like
1Likes
Like

Posted 25 September 2012 - 03:53 PM

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.

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.