我正在为 Unity 中的增强现实应用程序开发一个透明阴影接收着色器,它被放入一个平面中,该平面将接收来自点光源或聚光灯的阴影。它工作正常,但是正如您在图像中看到的那样,飞机也接收到光。
我正在使用统一 5.6.3p4。请告诉我此脚本中可能存在什么问题,或者我应该在此代码中进行哪些更改以仅接收阴影而不接收平面上的光反射?
着色器脚本如下:
Shader "SP/InvisibleShadowCasterForPLight" {
Properties {
_MainTex("Base (RGB)", 2D) = "white" {}
}
SubShader {
Pass {
Blend One One
Tags { "LightMode" = "ForwardAdd" }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
#pragma multi_compile_fwdadd_fullshadows
#include "AutoLight.cginc"
sampler2D _MainTex;
float4 _MainTex_ST;
struct v2f {
float4 pos : SV_POSITION;
LIGHTING_COORDS(0,1)
float2 uv : TEXCOORD2;
};
v2f vert(appdata_base v) {
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
fixed4 frag(v2f i) : COLOR
{
float attenuation = LIGHT_ATTENUATION(i);
return tex2D (_MainTex, i.uv) * attenuation;
}
ENDCG
}
}
Fallback "VertexLit"
}