Jump to content
  • Advertisement
Sign in to follow this  
littlekid

Directx10 Shader Semantic

This topic is 3780 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is there a need to follow the Semantic in directx10 shader model? Example POSITION, TEXCOORD, NORMAL0, etc. I was wondering since in directx10, the creation of the InputLayout actually specifies the semantics to bind the input data to, there wouldn't be a need to follow thoes Semantics. Example is it perfectly alright to do this:
D3D10_INPUT_ELEMENT_DESC InputElementDesc[] =
{
  {"MYPOS", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },  
  {"MYTEX", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D10_INPUT_PER_VERTEX_DATA, 0 },
};

HLSL:
struct VS_INPUT
{
   float4 Pos : MYPOS;
   float2 Tex : MYTEX;
};

struct VS_OUTPUT
{
   float4 Pos : SV_POSITION;
   float4 Tex : NEWTEXCOORD;
};

VS_OUTPUT VS( VS_INPUT input )
{
    VS_OUTPUT output = (VS_OUTPUT)0;
    output.Pos = mul( input.Pos, World );
    output.Pos = mul( output.Pos, View );
    output.Pos = mul( output.Pos, Projection );
    output.Tex = input.Tex;
    return output;
}

float4 PS( VS_OUTPUT input) : SV_Target
{
    return txDiffuse.Sample( samLinear, input.Tex );
}

I am just curious as to is there a need to follow the standard semantic that was used (POSITON0, TEXCOORD etc)?

Share this post


Link to post
Share on other sites
Advertisement
You can use whatever semantic names you like. Your example should be mostly fine.

The only restriction is that the required system-interpreted semantics are present (ie SV_Position for VS/GS output, SV_Target for PS output)

Share this post


Link to post
Share on other sites
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!