ShaderLab
The Unity shader documentation says:
All Shaders files in Unity are written in a declarative language called “ShaderLab”. In the file, a nested-braces syntax declares various things that describe the shader – for example which shader properties should be shown in material inspector; what kind of hardware fallbacks to do; what kind of blending modes to use etc.; and actual “shader code” is written in CGPROGRAM snippets inside the same shader file
The basic ShaderLab syntax for a shader is:
Shader "name" { [Properties] Subshaders [Fallback] [CustomEditor] }
These features are all well documented; the important thing to notice is that the Pass
is that it can contain snippets of Cg/HLSL, which typically looks like:
Pass {
// ... the usual pass state setup ...
CGPROGRAM
#pragma surface surfaceFunction lightModel [optionalparams]
// the Cg/HLSL code itself
ENDCG
// ... the rest of pass setup ...
}
Much of documentation around shaders in Unity unhelpfully says:
You still write shader code in Cg / HLSL.
The reason is that broadly speaking they are syntactically identical; they are both variations on the syntax of the C
programming language.