variable ‘o‘ used without having been completely initialized Compiling Vertex program
v2f vert (appdata_base v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
float3 V = WorldSpaceViewDir(v.vertex);
V = mul(unity_WorldToObject, float4(V,1));
o.NdotV.x = saturate(dot(v.normal, normalize(V)));
return o;
}
使用宏初始化 v2f 即可 UNITY_INITIALIZE_OUTPUT
修改为
v2f vert (appdata_base v)
{
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f,o);
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
float3 V = WorldSpaceViewDir(v.vertex);
V = mul(unity_WorldToObject, float4(V,1));
o.NdotV.x = saturate(dot(v.normal, normalize(V)));
return o;
}