1

I'm trying to write a basic Unlit shader that also receives shadows.

The following code below works almost as expected, except that I get a weird dark area as you can see on this image. Can anybody help me to understand what I'm doing wrong?

Any feedback would be much appreciated!

Shader "Unlit/TextureReceive"
{
    Properties
    {
        _MainTex ("Base (RGB)", 2D) = "white" {}
    }

    SubShader
    {
        Pass
        {
            Tags { "LightMode" = "ForwardBase" }

            CGPROGRAM

            #pragma vertex vert
            #pragma fragment frag
            #include "UnityCG.cginc"
            #pragma multi_compile_fwdbase
            #include "AutoLight.cginc"

            struct appdata_t
            {
                float4 vertex : POSITION;
                float2 texcoord : TEXCOORD0;
            };

            struct v2f
            {
                float4 pos : SV_POSITION;
                float2 texcoord : TEXCOORD0;
                LIGHTING_COORDS(0,1)
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;

            v2f vert(appdata_t v)
           {
                v2f o;
                o.pos = UnityObjectToClipPos (v.vertex);
                o.texcoord = TRANSFORM_TEX(v.vertex, _MainTex);
                TRANSFER_VERTEX_TO_FRAGMENT(o);

                return o;
            }

            fixed4 frag(v2f i) : COLOR
            {
                fixed4 col = tex2D(_MainTex, i.texcoord);

                 float attenuation = LIGHT_ATTENUATION(i);
                 return col * clamp(attenuation, 0, 1);
            }

            ENDCG
        }
    }

    Fallback "VertexLit"
}
Florian
  • 21
  • 2

0 Answers0