Jump to content
  • Advertisement
Sign in to follow this  

DX11 Vertex shader input fills "missing" values?

Recommended Posts

I'm reviewing a tutorial on using textures and I see that the vertex shader has this input declaration where the position is float4

struct VertexInputType
    float4 position : POSITION;
    float2 tex : TEXCOORD0;

But when they go over uploading the data to vertex buffer they only use a float3 (Vector3) value for the position

// Load the vertex array with data.
vertices[0].position = D3DXVECTOR3(-1.0f, -1.0f, 0.0f);  // Bottom left.
vertices[0].texture = D3DXVECTOR2(0.0f, 1.0f);

vertices[1].position = D3DXVECTOR3(0.0f, 1.0f, 0.0f);  // Top middle.
vertices[1].texture = D3DXVECTOR2(0.5f, 0.0f);

vertices[2].position = D3DXVECTOR3(1.0f, -1.0f, 0.0f);  // Bottom right.
vertices[2].texture = D3DXVECTOR2(1.0f, 1.0f);

The input layout description declared also seems to match to use a float3 value

polygonLayout[0].SemanticName = "POSITION";
polygonLayout[0].SemanticIndex = 0;
polygonLayout[0].Format = DXGI_FORMAT_R32G32B32_FLOAT;
polygonLayout[0].InputSlot = 0;
polygonLayout[0].AlignedByteOffset = 0;
polygonLayout[0].InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
polygonLayout[0].InstanceDataStepRate = 0;

So does this mean that shaders will automatically default "missing" values to 0 or something of the like? If so is this frowned upon?

Edited by noodleBowl

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
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!