1
votes

I use the following shader in unity 4.6.2, but unfortunately it doesn't work in unity5. I have an object in an AR scene (vuforia 4) and I want to show the shadows on a plane which is under the object. That plane should be transparent and only show the shadows, like in the picture.

Like in this picture here

this is the shader which works in unity 4.6.2

Shader "TransparentShadowShader" {

Properties
{
    _ShadowColor ("Shadow Color", Color) = (0,0,0,1)
}

Category {

Blend  SrcAlpha OneMinusSrcAlpha

Lighting Off
Zwrite Off
LOD 200


SubShader
{
    Tags { "RenderType"="Transparent" }

    CGPROGRAM
    #pragma surface surf Custom

    struct Input {
        float2 pos : POSITION;
    };

    uniform float4 _ShadowColor;

    void surf(Input IN, inout SurfaceOutput o)
    {
        //Pass through shadow colour to lighting model
        o.Albedo = _ShadowColor.rgb;
        o.Alpha  = _ShadowColor.a;
    }

    half4 LightingCustom(SurfaceOutput s, half3 lightDir, half3 viewDir, half atten)
    {
        half4 c;

        //Inverse illumination - atten accounts for shadowing
        c.rgb = s.Albedo.rgb * 1.0f-atten;
        c.a   = s.Alpha * 1.0f-atten;

        return c;
    }
    ENDCG
}
}

Fallback "VertexLit", 2

}

this is what I am getting in unity5, using this shader

enter image description here

1
Can you explain in what way the shader doesn't work? - bwroga
I added a picture of the shader.. It looks like it is inverted or something. - Jenny
@Jenny have you found a solution ? - Augmented Jacob

1 Answers

-1
votes

Okay, already looked for the answer on this one, everything was simpler, than expected

Shader "Invisible/InvisibleShadowCaster" {
 SubShader {
     Tags { 
         "Queue"="Transparent"
         "RenderType"="Transparent" 
     }
     CGPROGRAM
     #pragma surface surf Lambert alpha addshadow

     struct Input {
         float nothing; // Just a dummy because surf expects something
     };

     void surf (Input IN, inout SurfaceOutput o) {
         o.Alpha = 0;
     }
     ENDCG
 } 
 FallBack "Diffuse"}

this worked perfectly for me, try it