What is the general purpose SEMANTIC for the float data in a shader?

Started by
3 comments, last by eu5 2 years, 10 months ago

Hi.

When you want to pass a float data from a vertex shader to a pixel shader,
What should I give the semantic to float data?

In the MS docs, there are a few sematics for float such as BLENDWEIGHT, PSIZE, FOG.
But I think this is not for my data.

My data is the distance from the light to current vertex.
Actually, the distance is normalized. So It ranged [0, 1]

struct VS_OUTPUT
{

float DistanceLightToVertex : ???; // [0, 1]
};

Advertisement

For passing arbitrary data, you can name the semantic anything you want - as long as its unique.

struct VS_OUTPUT
{
…
float DistanceLightToVertex : FLOATY_MC_FLOATFACE; // yes, this compiles
};

You only need to use system-defined semantics if you want to use specific features (pretty much everything with SV_); and others in my understanding are mostly only there to aid in readabilitys/debugability (TEXCOORD, NORMAL) - but I might be wrong about the latter.

In D3D9 there were a fixed number of semantics that you could use for passing between VS and PS. In that era you would have used TEXCOORD for generic floating-point data. In D3D10 in newer the non-SV semantics are completely arbitrary, and are really only used for validation. In reality the binding between VS and PS is based on the order that the values are declared, so you just need to make sure that matches between VS and PS.

Thank you guys!

This topic is closed to new replies.

Advertisement