Unlit Shader with Shadows from point lights.

Hi guys, I’m really a noob at shader coding, I found this shader that does almost what I need but has a problem, I need an object to be unlit, has a texture, and receives shadows form directional lights and point lights, specially the last one.
The idea is that I will have a quad or plane (facing up) in which I’ll be loading an image or movie texture, and the objects on top of it should cast shadows on this quad or plane. I need ir to receive shadows caused by a point light because thats what my client needs.

Here is the shader that receive shadows only from a directional light, I would need someone to add the point light support.

Shader “UnlitShadows/UnlitShadowReceive” {
Properties{ _MainTex(“Base (RGB)”, 2D) = “white” {} }
SubShader{ Pass{ SetTexture[_MainTex] } Pass { Blend DstColor Zero Tags{ “LightMode” = “ForwardBase” }
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include “UnityCG.cginc”
#pragma multi_compile_fwdbase
#include “AutoLight.cginc”
struct v2f {
float4 pos : SV_POSITION; LIGHTING_COORDS(0,1) };
v2f vert(appdata_base v) {
v2f o; o.pos = mul(UNITY_MATRIX_MVP, v.vertex); TRANSFER_VERTEX_TO_FRAGMENT(o);
return o; }
fixed4 frag(v2f i) : COLOR{
float attenuation = LIGHT_ATTENUATION(i);
return attenuation;
} ENDCG } } Fallback “VertexLit” }

Thanks in advance!!!

Shader “UnlitShadows/UnlitShadowReceive” {
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" 

            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 = mul(UNITY_MATRIX_MVP, 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 
        } 

        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 = mul(UNITY_MATRIX_MVP, 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" 
}

Wow! That’s fantastic. Thanks so much for sharing this!

There is just one thing I noticed…
When I apply the shader to my unlit texture the shadows on the object are completely black.
While the shadows casted on a Standart Material are slightly transparent. Is there any way to match the darkness of the shadows? So that the shadows on the unlit material are also slighly transparent? That would be awesome. Thanks in advance…

@Namey5
hello,
i know this is really old thread!!

but … is it possible to using that on HDRP??

i wants an HDRP Unlit shader with cast-receive shadow … does exists an shader for that??