I’ve written the following shader, and I don’t understand why every object with this shader receives lighting when another object does.
Shader "Ghost/Photophobia" {
Properties {
_Texture ("Texture (RGB)", 2D) = "white" {}
}
SubShader {
Tags {
"Queue" = "Transparent"
}
Pass {
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_builtin_noshadows
#pragma fragmentoption ARB_fog_exp2
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
#include "AutoLight.cginc"
struct v2f {
V2F_POS_FOG;
LIGHTING_COORDS
float2 uv;
float3 lightDir;
float3 normal;
};
float4 _Texture_ST;
v2f vert (appdata_tan v) {
v2f o;
PositionFog(v.vertex, o.pos, o.fog);
o.normal = v.normal;
o.uv = TRANSFORM_TEX(v.texcoord, _Texture);
o.lightDir = ObjSpaceLightDir(v.vertex);
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
sampler2D _Texture;
half4 frag (v2f i) : COLOR {
half4 textureColor = tex2D(_Texture, i.uv);
half4 c = DiffuseLight( i.lightDir, i.normal, textureColor, LIGHT_ATTENUATION(i) );
c.a = -((c.r + c.b + c.g) / 3) + 1;
return c;
}
ENDCG
}
}
}
In the image below, there is a sphere and a capsule with my shader applied (they each have a red and green texture). When I shine the spot light on either cube (default diffuse shader), the same sized spot shows up on the sphere and the capsule in the same relative location.
I get nothing when shining light on the sphere or the capsule directly. What am I doing wrong?