Projector is showing through other objects

Hey guys, so I’ve been working on my main character and he’s got a hood. So I thought, “Hey, wouldn’t it be cool if the hood put a shadow over his face?!”. I immediately thought of the Projector and made a pretty good looking shadow on his face:

The projector is ignoring the hood so it just shows up on the face… but, there is a problem: the shadow kinda bleeds/shows through the hood. Here’s what I mean:

9365-capture5.jpg

I’ve tried so many different things, but nothing’s preventing the shadow from ‘bleeding’ through! Any ideas?

Haha, solved it. Weird solution, but I found a projector shader that doesn’t do it.

Shader "Cg projector shader for drop shadows" {
   Properties {
      _ShadowTex ("Projected Image", 2D) = "white" {}
   }
   SubShader {
      Pass {      
          Blend Zero OneMinusSrcAlpha // attenuate color in framebuffer 
            // by 1 minus alpha of _ShadowTex 
         CGPROGRAM
 
         #pragma vertex vert  
         #pragma fragment frag 
 
         // User-specified properties
         uniform sampler2D _ShadowTex; 
 
         // Projector-specific uniforms
         uniform float4x4 _Projector; // transformation matrix 
            // from object space to projector space 
 
          struct vertexInput {
            float4 vertex : POSITION;
            float3 normal : NORMAL;
         };
         struct vertexOutput {
            float4 pos : SV_POSITION;
            float4 posProj : TEXCOORD0;
               // position in projector space
         };
 
         vertexOutput vert(vertexInput input) 
         {
            vertexOutput output;
 
            output.posProj = mul(_Projector, input.vertex);
            output.pos = mul(UNITY_MATRIX_MVP, input.vertex);
            return output;
         }
 
 
         float4 frag(vertexOutput input) : COLOR
         {
            if (input.posProj.w > 0.0) // in front of projector?
            {
               return tex2D(_ShadowTex , 
                  float2(input.posProj) / input.posProj.w); 
               // alternatively: return = tex2Dproj(  
               //    _ShadowTex, float3(input.posProj));
            }
            else // behind projector
            {
               return float4(0.0);
            }
         }
 
         ENDCG
      }
   }  
   // The definition of a fallback shader should be commented out 
   // during development:
   // Fallback "Projector/Light"
}

Hi,

I have this problem, Can you you help me out ??

I tried using your shader, But it giving a transparent image as output.

to quaker-sdr

maybe second hint will help…

@Glacier Games : I also couldn’t get this to work - it goes through objects and reverses the pattern. I’m using Unity 5.0.1

Amazing!!, can you send me the projector prefab with the shader,