Alpha Channels

I’m using the following shader to simulate a window shade. It requires 2 textures, one for the material, one the mask. Testing it, I pic any material, and an image that know has a working alpha channel for the mask. So far so good. Well, the mask was actually a image I was using as a decal for a basket ball court. But if fill in the rest of the image, is should work. Nope. It’ll let me edit it to a point, but if i fill it with the paint tool. it stops working or reverses how it masks. I’ve had trouble with alpha channels in the past, in part because I was using an old version of paint shop pro. Anyway, what do I need to know about alpha channels to make them work reliably? Thanks.

Shader "Custom/Window" 
{
Properties 
{
	_Color ("Main Color", Color) = (1,1,1,0.5)
	_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
	_Mask ("Mix Mask (A)", 2D) = "white" {}
}
SubShader {
//  ZWrite Off
//    Alphatest Greater 0
    Tags {Queue=Transparent}
   	Lighting Off Cull Off ZTest Always ZWrite Off Fog { Mode Off }

    Blend SrcAlpha OneMinusSrcAlpha  
	Pass 
	{
//		Lighting On
		
		Material {
			Diffuse [_Color]
//			Ambient [_Color]
//			Emission [_PPLAmbient]
		}
		SetTexture [_MainTex] {
			constantColor [_Color]
			combine texture * constant, texture * constant
		}
		SetTexture [_Mask] {
			combine previous, texture
		}
		SetTexture [_MainTex] {
			combine previous * texture
		}
	}
}

FallBack " VertexLit", 1
}

Paint shop! highfive

I still use PSP exclusively. I just love how “B” means “Brush” and “S” means “Select”. I can’t wrap my head around Photoshop’s screwball shortcuts.

Anywho:

A mask is an on-or-off indicator. Wherever the mask is “on” (which is usually white, i believe), the other image will show. Wherever the mask is “off” (black), the image will not appear at all. (essentially the mask’s lightness multiplies the alpha of the other image, which is assumed to default to 1.0 in all places).

In PSP - and I have no idea how to do this in Photoshop - if you Select All, then Selection > Invert, then Selection > Save as Alpha Channel, the alpha channel will be the mask for that image - hopefully that can help you visualize what’s going on. (this only works if you have transparency in your image already; if you’re using a color for transparency like in the image below - the garish blue - then you need to select everything that isn’t that color instead)

Oh, also, if you save as PNG, it has natural transparency. You could, for example, paint with a 50% opacity brush and have a translucent ball or whatevs.