Jump to content

  • Log In with Google      Sign In   
  • Create Account


Vertex attributes default values ?

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

#1 wil_   Members   -  Reputation: 278

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.

 

 

 



Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 13433

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.

It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 wil_   Members   -  Reputation: 278

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.






PARTNERS