Jump to content

  • Log In with Google      Sign In   
  • Create Account

Vertex attributes default values ?


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 wil_   Members   -  Reputation: 583

Like
0Likes
Like

Posted 28 August 2014 - 09:06 PM

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.

 

 

 



#2 L. Spiro   Crossbones+   -  Reputation: 23975

Like
6Likes
Like

Posted 28 August 2014 - 09:14 PM

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

Edited by L. Spiro, 28 August 2014 - 09:16 PM.


#3 wil_   Members   -  Reputation: 583

Like
0Likes
Like

Posted 28 August 2014 - 09:18 PM

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


Edited by wil_, 28 August 2014 - 09:19 PM.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.




PARTNERS