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 shaderA small script that contains the mathematical calculations and algorithms for calculating the Color of each pixel rendered, based on the lighting input and the Material configuration. More info
See in Glossary
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 CoreThe back-end Unity uses to support the latest OpenGL features on Windows, MacOS X and Linux. More info
    See in Glossary
    , 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 ShadersUnity’s code generation approach that makes it much easier to write lit shaders than using low level vertex/pixel shader programs. More info
    See in Glossary
    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.

See Also

GLSL Shader programs
Shader Compilation Target Levels