Transparent plane with RenderTexture - no show shadows?

Hey Hey,
i know there are some more threads about this all over main portals but none really matched my needs…

I am trying to stream a cameras view, which sees objects and shadows but not the surface the shadow receives, to a RenderTexture.
To get a shadow on a transparent surface, i found several working shaders like this (Unity3d Vuforia AR Shadows tutorial - YouTube)

The RenderTexture is supposed to be on a transparent surface as well so it only shows the objects and their shadows.
The Problem is, that the receiving plane doesn’t show the shadow and i can’t see why…

Does anybody have any suggestions?


I use this shader to create a material which only shows shadows and apply transparency to rest of the area. Create a new shader and copy the below code and compile. Than change the material from Standard to FX>MatteShadow

Shader "FX/Matte Shadow" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
    _Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}

SubShader {
    Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
    LOD 200
    Blend Zero SrcColor
 
CGPROGRAM
 
#pragma surface surf ShadowOnly alphatest:_Cutoff
 
fixed4 _Color;
 
struct Input {
    float2 uv_MainTex;
};
 
inline fixed4 LightingShadowOnly (SurfaceOutput s, fixed3 lightDir, fixed atten)
{
    fixed4 c;
 
    c.rgb = s.Albedo*atten;
    c.a = s.Alpha;
    return c;
}

void surf (Input IN, inout SurfaceOutput o) {
    fixed4 c = _Color;
    o.Albedo = c.rgb;
    o.Alpha = 1;
}

ENDCG
}
Fallback "Transparent/Cutout/VertexLit"
}

@maechtigerhoros
@neosca
Hello,
do I understand correctly that the subject of the question (and answer) is something in 3D graphics commonly called as matte shadow?

I can reccomend the free shader from Unity guy Keigiro Takahashi, which allows to adjust also the color and transparency of the shadows:

It has however the same drawback as the one provided by Neosca - it does not work against skyboxes - only against the solid color or another object (plane - floor, wall).
Unfortunately it seems to be caused by Unity design itself :frowning:

Hope it helps a little

Does this still work with the current Unity version? I have trouble to get it to work as expected. The shadows are visible but so is the plane.

Some feedback would be gret since I am unsure if the problem is with my set up or in general with the shader.

Thanks,
Daniel