In Unity, shader programs are written in a variant of HLSL language (also called Cg but for most practical uses the two are the same).
Currently, for maximum portability between different platforms, writing in DX9-style HLSL (e.g. use DX9 style sampler2D
and tex2D
for texture sampling instead of DX10 style Texture2D
, SamplerState
and tex.Sample
).
Internally, 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 are used for shader program compilation:
In case you really need to identify which compiler is being used (to use HLSL syntax only supported by one compiler, or to work around a compiler bug), predefined shader macros can be used. For example, UNITY_COMPILER_HLSL
is set when compiling with HLSL compiler (for D3D or GLCore/GLES3 platforms); and UNITY_COMPILER_HLSL2GLSL
when compiling via hlsl2glsl.