Issue with a simple Unlit receive shadow shader
Hello guys, I'm trying to write a basic Unlit shader that would also receive shadows.
The following code (below) works almost as expected, except that I get a weird dark area as you can see on the image attached. Can anybody help me to understand what I'm doing wrong?
Shader "Unlit/TextureReceive"
{
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Tags { "LightMode" = "ForwardBase" "RenderType"="Opaque" }
LOD 100
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma target 2.0
#pragma multi_compile_fog
#include "UnityCG.cginc"
#include "AutoLight.cginc"
struct appdata_t {
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};
struct v2f {
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
UNITY_FOG_COORDS(1)
LIGHTING_COORDS(2,3)
};
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata_t v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col = tex2D(_MainTex, i.texcoord);
UNITY_APPLY_FOG(i.fogCoord, col);
UNITY_OPAQUE_ALPHA(col.a);
float attenuation = LIGHT_ATTENUATION(i);
return col * attenuation;
}
ENDCG
}
}
}
Any feedback would be much appreciated!
ezgifcom-optimize.gif
(406.9 kB)
Comment
Your answer
Follow this Question
Related Questions
Shadows on Custom Lit Surface Shader 1 Answer
Isometric sprite shadows mapping 0 Answers
How to cast terrain detail shadow? 0 Answers
How to make SSAO ignore a mesh? 0 Answers
Shadows are black. 0 Answers