Wednesday, July 27, 2016

Multi Vertex Buffer And Inputlayout

Multi Vertex Buffer And Inputlayout

Hellow!

I'm going to do skin mesh, I don't know whether I 'm in the right way.

Here's the code:

struct Vertex1 
{

  float3 pos;

  float3 normal;

  float2 texcoord;

};

 

struct Vertex2 
{

  float4 weights;

  float4 ids;
};

 

And I have 2 vertex stream,  std::vector<Vertex1> v1,  std::vector<Vertex2> v2, then I use these 2 stream to create two vertex buffer  vb1 and vb2;

The question is : 

How to set vertex buffer?   VSSetVertexBuffer( 0, 1, &vb1);   VSSetVertexBuffer( 1, 1, &vb2);

How big the stride ?  sizeof(Vertex1) + sizeof(Vertex2) ?

 

Another question is :

If I want to combine the two kind of vertex, how can I do ? 

 

The new Vertex look like this: 

struct Vertex
{

  float3 pos;

  float3 normal;

  float2 texcoord;

  float4 weights;

  float4 ids;
};

If the mesh is not skined, I just use pos,normal,texcoord,   can I set the stride to sizeof(pos) + sizeof(normal) + sizeof(texcoord)?  and use a input layout with 3 elements?

When the mesh is skined, the whole Vertex will be used, and the input layout will be 5 elements.

 

 

 

 


No comments:

Post a Comment