Ox00 Surface Shader Syntax
常用的三种输出数据格式:
//Standard output structure of surface shaders is this:
struct SurfaceOutput
{
fixed3 Albedo; // diffuse color
fixed3 Normal; // tangent space normal, if written
fixed3 Emission;
half Specular; // specular power in 0..1 range
fixed Gloss; // specular intensity
fixed Alpha; // alpha for transparencies
};
//Unity 5版本以上, 支持physically based lighting models.
struct SurfaceOutputStandard
{
fixed3 Albedo; // base (diffuse or specular) color
fixed3 Normal; // tangent space normal, if written
half3 Emission;
half Metallic; // 0=non-metal, 1=metal
half Smoothness; // 0=rough, 1=smooth
half Occlusion; // occlusion (default 1)
fixed Alpha; // alpha for transparencies
};
//镜面高光输出
struct SurfaceOutputStandardSpecular
{
fixed3 Albedo; // diffuse color
fixed3 Specular; // specular color
fixed3 Normal; // tangent space normal, if written
half3 Emission;
half Smoothness; // 0=rough, 1=smooth
half Occlusion; // occlusion (default 1)
fixed Alpha; // alpha for transparencies
};
?
0x01 Surface Shader compile directives
Surface shader编码在CGPROGRAM...ENDCG块内,
- 必须在Subshader块内而不能在pass内部,Surface shader将自己编译成多个通道.
- 必须使用#pragma surface surfaceFunction lightModel [optionalparams] 指令来表明这是surface shader.
拆分#pragma surface surfaceFunction UnityShader基础效果-Surface Shader
原文地址:https://www.cnblogs.com/baolong-chen/p/11621189.html