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
}
}
}
}