directx/HLSL what are input and output semantics for?
Asked Answered
P

1

6

i was wondering what those input and output semantics in HLSL are for? i.e. why do i have to write that TEXCOORD0;

struct VS_OUTPUT 
{
   float2 tc : TEXCOORD0; 
};

when the type and the name are already given?

Prelate answered 24/3, 2011 at 20:51 Comment(0)
R
4

Semantics let the shader know where to read or write data from. They correspond to parts of the vertex structure or certain values.

In your example above, the value of tc comes from the first texture coordinate component.

For info on semantics and what they mean, check here: http://msdn.microsoft.com/en-us/library/bb509647(v=vs.85).aspx

In the vertex shader, the data will be coming from the FVF or vertex declaration.

Ragi answered 24/3, 2011 at 22:13 Comment(2)
well, but for passing data from vertex to pixelshader i can freely choose what semantics to use, right? for example for a normalvector i can use COLOR4.Prelate
I think there are still some restrictions, and you should generally go sequentially, but between the two stages is left mostly to the shader's discretion, yes. The input to the vertex stage and output from the pixel need to match the program's expectations.Ragi

© 2022 - 2024 — McMap. All rights reserved.