Advertisement

Multiple vertex buffers and Input slots Question

Started by October 30, 2017 06:51 PM
2 comments, last by Tubby94 7 years, 3 months ago

EDIT: I have now solved my problem after trail and error

 

Hi All,

I'm following Frank Luna's book, Introduction to 3D Game Programming with Directx 12, and have come to the point where there is an exercise to create a cube using 2 Vertex buffers; one for position, and one for color. I'm then supposed to bind these to different Input slots(0 and 1).

All is fine except my color data seems to be misinterpreted by the pipeline, no matter what color I specify to the vertices in my buffer, the cube will still be rendered as a predetermined assortment of colors. Am I missing anything important to achieving this goal? these are the steps I took so far:

Used Two vertex buffers to feed pipeline with vertices

struct VPosData {XMFLOAT3 Pos; };

struct VColorData {XMFLOAT4 Color; };  

Changed INPUT_ELEMENT_DESC accordingly

mInputLayout =
{
    { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, 
          D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 },

    { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 1, 0, 
         D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, 0 }
};

Bound the two vertex buffers to the input slots

mCommandList->IASetVertexBuffers(0, 1, &mBoxGeo->VertexBufferView()); //Input Slot 0 for verts

mCommandList->IASetVertexBuffers(1, 1, &mBoxGeo->VertexBufferView()); //Input Slot 1 for Color

The Textbook doesn't specify any extra steps to achieve this result, so at this point I'm not sure how to go about debugging this problem. Any feedback would be appreciated.

Seems to me like you are binding the same buffer twice, which is probably not what you want.

Advertisement
2 minutes ago, turanszkij said:

Seems to me like you are binding the same buffer twice, which is probably not what you want.

Yeah I figured this out after a lot of trail and error, I had to create another buffer that will hold the color data. Thanks for the reply

This topic is closed to new replies.

Advertisement