To use the surface shaders, you need to define a surface function (
void surf(Input IN, inout SurfaceOutput o)) that takes any UVs or data you need as input, and fills in the output structure
SurfaceOutput structure basically describes properties of the surface (that is albedo color, normal, emission, specularity, and so on). Then, you write this code in Cg/HLSL.
Surface shader compiler then figures out the inputs that are needed, the outputs that are filled, and so on, and generates actual vertex and pixel shaders as well as rendering passes to handle forward and deferred rendering.
The surface shaders placed inside
CGPROGRAM...ENDCG block, must be placed inside the
SubShader block, and uses the
#pragma surface ...