Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'd say there are 3 kinds of HLSL semantics:

  • SV_* group - these are "system value" semantics which DO carry special meanings (e.g. assign special input/output data to/from shader stages)
  • predefined semantics - e.g. NORMAL, POSITION and so on... They are mentioned in the docs but I failed to find any special meaning assigned to them
  • semantics defined be the user - which can be anything (e.g. MY_AWESOME_TEXTURE_SEMANTIC) which apparently have no special meaning either

In addition, the docs say that more than one input/output value can have the same semantic assigned (e.g. 'NORMAL2 and NORMAL2). I guess that it doesn't include the SV_* group, though.

So besides the first group - do semantics carry any meaning at all? Do they even serve any purpose at all? :P

share|improve this question
    
In D3D10-11 there are actually no predefined semantics anymore besides the SV_* ones. Predefined names like NORMAL, POSITION etc. were used in D3D9, and of course you can still use those names if you like, but as far as the compiler is concerned, they're user-defined semantics. So there are only 2 kinds of semantics really: system values and user-defined ones. –  Nathan Reed Feb 23 at 2:19

1 Answer 1

up vote 3 down vote accepted

Do they even serve any purpose at all?

Yes for the user and developer of the shader, semantics conveys information about the intended use of a parameter. So you will know that POSITION is intended to be used as vertex position, NORMAL as vertex normal etc. Think of this as in-code documentation (not strictly the same though).

Do semantics carry any meaning at all?

They don't carry a meaning for the system, as they are not interpreted, but again for the user. You don't want to give vertex position a NORMAL semantic, it's really like deceiving the user/developer of the shader, it's confusing, it's like writing wrong documentation.

share|improve this answer
    
Ok, so why are they there in the first place (we can document the code with comments)? Except the SV_* group, of course. Historical remains? –  NPS Feb 22 at 20:47
    
@NPS It's like the en.wikipedia.org/wiki/Named_parameter idiom used in some languages it gives the code more clarity. you can't force comments though. –  concept3d Feb 22 at 20:58
    
So do you say THE ONLY reason for their existence is code clarity? :P –  NPS Feb 22 at 21:43
    
@NPS Yes. GLSL for example doesn't do that same, so if you want to tell the attributes semantics you do this by actually naming the parameters. For example you say, in vec2 textureCoord. if you said in vec3 t that could be texture coords or tangents. adding the semantics clarifies this without reading the code. –  concept3d Feb 22 at 21:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.