Shader表面着色器
包含四个函数:
- 顶点变换函数
- 表面着色函数
- 光照模型
- 最终颜色修改函数
定义入口函数
- pragma surface 入口函数名称 光照模型 [Options]
surface surf(Input IN, Inout SurfaceOutput o);
- 光照模型
(1)系统内置:Lambert漫反射光照、BlinnPhong高光光照
(2)自定义光照
half4 Lighting<Name>(SurfaceOutput s, half3 lightDir, half atten);
half4 Lighting<Name>(SurfaceOutput s, half3 lightDir, half3 viewDir, half atten);
half4 Lighting<Name>(SurfaceOutput s, half4 lightDir);
可选参数 - vertex
void <Name>(inout appdate_full v)
只需修改顶点着色器中的输入顶点数据;
half4 <Name>(inout appdate_full v, out inout o)
修改输入顶点数据,以及为表面着色器传递数据; - final color最终颜色修改函数
void <Name>(Input IN, SurfaceOutput o, inout fixed4 color);