Unity Semantic Semantics

Source: Internet
Author: User

Just beginning to contact shader may be confused about TEXCOORD0, Sv_target, Sv_position, and so on, these fields indicate what meaning, the following is to chat about its former present.

"Semantics", as the name implies, to interpret the meaning of something, if previously exposed to CG, HLSL programming, it may be very familiar with. To put it bluntly, semantics allows shader to know where to get the data and to know where to place the output data .

Then in unity, using TEXCOORD0 to decorate texcoord,unity will recognize TEXCOORD0 semantics and then populate the first set of textures in the model into Texcoord.

Of course, some people may be confused about the semantics of the SV Start is God horse East,SV is actually the meaning of System-value (System value) , it is necessary to note that SV begins with the semantics of the expansion of the platform, so can use the semantics of the SV beginning to use the semantics of the start of SV, Eliminate the hassle of cross-platform.

Model → Vertex shader common semantics

  POSITION: Vertex position
  Normal: vertex normal
  TANGENT: Vertex tangent
  Texcoord0-texcoordn (Unity built-in structure seems to support 6): Vertex texture coordinate
  color: vertex color

Vertex shader → fragment shader

  Sv_position: Vertex coordinates in clipping space
  COLOR0: Vertex color
  COLOR1: Vertex color
  texcoordn: texture coordinates

Fragment Shader output semantics:

Sv_target: The output value is directly used to render the

The last thing to note is that if the parameter or return value of the function in the shader is a struct, do not give a semantic value to the struct, not to mention that the novice does not understand that it is really doing so. If you do not understand the welcome message exchange.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.