appdata中的顶点变量命名必须为vertex
struct appdata
{
float4 vertex
: POSITION;
float2 uv
: TEXCOORD0;
float3 normal
: NORMAL;
};
v2f中顶点变量命名必须为pos
struct v2f
{
float2 uv
: TEXCOORD0;
float4 pos
: SV_POSITION;
float3 worldNormal
: TEXCOORD1;
float3 viewDir
: TEXCOORD2;
SHADOW_COORDS(
4)
};
否则在vert方法中调用TRANSFER_SHADOW(o)方法时shader会报错:Shader error in 'XX': invalid subscript 'pos' 'ComputeScreenPos': no matching 1 parameter function at line 80 (on d3d11)