0

I have this following struct which I use to describe vertexes to input assembler stage:

struct Vertex3D
{
  XMFLOAT3 Position;      // position x, y, z
  XMFLOAT4 Color;    // color r, g, b, a
};

I know I could use

{"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}

To describe this structure if my position was of type XMFLOAT2.

Now I want to extend my struct into 3D space and I have tried to set the desriptor as follows:

{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0}

and my vertex shader is as follows (probably the simplest one possible)

void VertexShaderFunction( in float4 posIn : POSITION, in float4 colorIn : COLOR, out float4   posOut : SV_POSITION, out float4 colorOut : COLOUR ){
    posOut = posIn;
    colorOut = colorIn;
}

But changing the z coordinate in position doesn't seem to have any effect in the rendering of vertexes. So what would be the correct descriptor to bind into input assembler stage vertex buffer?

The amateur programmer
  • 1,238
  • 3
  • 18
  • 38
  • That looks fine to me for the position element. There is possibly an issue with your vertex shader or projection matrix – megadan Oct 25 '14 at 23:48
  • @megadan Also I'm planning to take the projection matrixes in to the vertex shader as `float4x4`. What would I need to add to my input descriptor then? – The amateur programmer Oct 26 '14 at 07:23
  • @megadan Would I just add four identifiers (one for each row of matrix) as follows: `{"INPUTMATRIX", rowNumber, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}`? – The amateur programmer Oct 26 '14 at 07:35
  • The projection matrix is normally passed via a global shader parameter, because it is equal for all vertices and can be shared. – Gnietschow Oct 26 '14 at 12:13

0 Answers0