What it does

HLSL is a language for GPU programs that calculate values such as vertex positions and surface colors. Shader Graph Custom Functions can use it. Unity converts and compiles the code for the target graphics API.

Figure: Conceptual relationship: Shader source → Platform compilation → GPU execution
Figure: Conceptual relationship: Shader source → Platform compilation → GPU execution

How to use it

HLSL can express GPU calculations in Unity shaders or Shader Graph Custom Functions. Vertex, fragment and compute stages have different inputs and instruction restrictions.

A concrete example

A UV-to-color calculation runs in a different place from a C# movement script. GPU vertex deformation does not automatically update CPU colliders or renderer bounds to the same shape.

How to check it

  1. Begin with a constant output, then visualize UVs and normals.
    Follow input, processing / condition, then output
    Follow input, processing / condition, then output
  2. Diagnose the first compilation message, target API, includes, types and coordinate spaces in that order.
    Follow input, processing / condition, then output
    Follow input, processing / condition, then output

Limitations

Supported features depend on stage/API; it is distinct from CPU-side C#.

References