Simple mask scripted to 'reveal' - setTexture question

I’m trying to modify a shader on the UnifyCommunity wiki that uses a mask.

What I would like is for the mask (simple black to white gradient) to slide up my plane, revealing the image from bottom to top. I have that all working (using setTextureOffset to slide the mask up), but right now it is just using the RGB of the mask to set the color of the Image. I want the alpha channel value of the mask to be used for the alpha channel of the Image, so as the mask slides up from black to white, it goes from hidden to fully visible (This is what I expected the maskedTexture shader to do, but alas, it requires a bit of a tweak).

Here’s the code:

Shader "MaskedTexture"
{
   
   Properties
   {
   	//_Color ("Color", Color) = (1,1,1,1)
      _MainTex ("Mask", 2D) = "white" {}
      _Image ("Image", 2D) = "white" {}
   }
   
   SubShader
   {
   
      Tags {"Queue"="Transparent"}
      Lighting Off
      ZWrite Off
      Blend SrcAlpha OneMinusSrcAlpha
      
      Pass
      {
         SetTexture [_Image] {
         	combine texture
//I would love it if i could write "combine texture, _MainTex.a" right here.
         }
         
         SetTexture [_MainTex] { //this is the mask
         	combine texture, previous
         }
      }
   }
}

Aha, I switched it to the following and it worked. Is this the best way to do it?

      Pass
      {
         SetTexture [_MainTex] //mask

         
         SetTexture [_Image] {
         	combine texture, texture * previous alpha 
         	//use the image for RGB, use mask alpha * image for Alpha
         }
         
         SetTexture [_MainTex] {
         	combine texture, previous
         }
      }

I don’t understand what the RGB relationship is between your two textures. However, the texture stages you just posted include a bit of redundancy, and can be reduced to

Pass 
{ 
	SetTexture [_Image]
	SetTexture [_MainTex] {Combine texture, texture * previous} 
}

“use the image for RGB”, from your comments, doesn’t matter, as the RGB gets overwritten in the shader fragment you posted.

After the comma, texture * previous alpha works, but texture * previous does the same thing, as you’re only operating on the alpha channel after the comma.

“use mask alpha * image for Alpha” concerns me, if you hadn’t fully grasped the previous idea. Are you expecting “texture * previous alpha” to be multiplying a greyscale version of the RGB channels? That’s what I think you’re implying, but unfortunately you can’t do that.

Yes, your way is correct. Thanks for the clarification.