Shader with BW gradient mask and cutoff for projector
Hi guys. Shader-noob here, but keen to learn. I'm trying to create a shader to use with a projector on the standard out-of-the-box pipeline. I'm halfway there. I want my projection to be masked/cutoff by the value of a second image which contains a black to white gradient. In this case it is a radial gradient.

Right now the gradient does nothing. I'll post my current code below. But my question is this. How do I take the value of black from the mask image and use it to progressively reveal the decal image above it?
 Shader "Projector/Cutout" {
     Properties{
         _DecalTex( "Decal", 2D ) = "white" {}
         _MaskTex( "Mask", 2D ) = "black" {}
         _Cutoff ( "Alpha cutoff", Range( 0, 1 ) ) = 0.5
     }
     Subshader {
         Tags {"Queue" = "AlphaTest" "RenderType" = "TransparentCutout"}
         Pass {
             ZWrite Off
             ColorMask RGB
             Blend OneMinusSrcAlpha SrcAlpha
             Offset -1, -1
  
             CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #pragma multi_compile_fog
             #include "UnityCG.cginc"
  
             struct v2f {
                 float4 uvShadow : TEXCOORD0;
                 UNITY_FOG_COORDS(2)
                 float4 pos : SV_POSITION;
             };
  
             float4x4 unity_Projector;
             float4x4 unity_ProjectorClip;
  
             v2f vert( float4 vertex : POSITION )
             {
                 v2f o;
                 o.pos = UnityObjectToClipPos( vertex );
                 o.uvShadow = mul( unity_Projector, vertex );
                 UNITY_TRANSFER_FOG( o, o.pos );
                 return o;
             }
  
             sampler2D _DecalTex;
             sampler2D _MaskTex;
             float _Cutoff;
  
             fixed4 frag(v2f i) : SV_Target
             {
                 fixed4 texDecal = tex2Dproj( _DecalTex, UNITY_PROJ_COORD( i.uvShadow ) );
                 texDecal.a = 1.0 - texDecal.a;
  
                 // clip( texDecal.a - ( _Cutoff ) );
                 // clip( texDecal.a );
                 clip( texDecal.a - _Cutoff );
  
                 UNITY_APPLY_FOG( i.fogCoord, texDecal );
                 return texDecal;
             }
             ENDCG
         }
     }
 }
Your answer
 
 
             Follow this Question
Related Questions
Can't Get Simple Transparency Shader To Work 1 Answer
After upgrading to version 5.3.4f1, my terrain shader no longer works 0 Answers
Custom Shader Giving Unexpected token error for period ' . ' 1 Answer
Additive Blending Shader for Mobile - parse error 1 Answer
Unity 5 Shader ignore self occlusion 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                