Version: 2019.3
GLSL Shader programs
Shader Compilation Target Levels

Shading language used in Unity

Unity’s shader programs uses a variant of the HLSL language. HLSL is sometimes called Cg but it’s worth bearing in mind that Unity does not use Cg.

Shader compilers

Different platforms use different shader compilers for shader program compilation as follows:

  • Windows and Microsoft platforms (DX11, DX12 and Xbox One) all use Microsoft’s HLSL compiler (currently d3dcompiler_47).
  • OpenGL Core, OpenGL ES 3, OpenGL ES 2.0 and Metal use Microsoft’s HLSL followed by bytecode translation into GLSL or Metal, using HLSLcc.
  • Other console platforms use their respective compilers (e.g. PSSL on PS4).
  • Surface Shaders use HLSL and MojoShader for code generation analysis step.

You can use predefined shader macros to identify which compiler Unity is using, for instance to use HLSL syntax only supported by one compiler, or to work around a compiler bug.

Смотрите так же

GLSL Shader programs
Shader Compilation Target Levels