Vertex attributes default values ?

Started by
1 comment, last by wil_ 9 years, 7 months ago

If I create a vertex buffer with data like this (code from DirectX SDK Tutorial07):

SimpleVertex vertices[] =
{
{ XMFLOAT3( -1.0f, 1.0f, -1.0f ), XMFLOAT2( 0.0f, 0.0f ) },
{ XMFLOAT3( 1.0f, 1.0f, -1.0f ), XMFLOAT2( 1.0f, 0.0f ) },
{ XMFLOAT3( 1.0f, 1.0f, 1.0f ), XMFLOAT2( 1.0f, 1.0f ) },
{ XMFLOAT3( -1.0f, 1.0f, 1.0f ), XMFLOAT2( 0.0f, 1.0f ) },
// ... etc

};

Bind it with this input layout:

D3D11_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};

To this vertex shader input in the shader:

struct VS_INPUT
{
float4 Pos : POSITION;
float2 Tex : TEXCOORD0;
};

Then is it guaranteed by D3D specification that the 4th component of the Pos attribute (Pos.w) in the shader will be 0.0 ?

I cannot find definitive information about it.

Advertisement
It is guaranteed that it will be 1.
http://msdn.microsoft.com/en-us/library/windows/desktop/bb944006(v=vs.85).aspx#Varying_Shader_Inputs_and_Semantics

If the data in the vertex stream contains fewer components than the corresponding shader data type, the missing components will be initialized to 0 (except for w, which is initialized to 1).



L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Ok, thanks for pointing me to relevant part of the documentation.

This topic is closed to new replies.

Advertisement