I have a shader working that has a sampler2D for a mask. Black is hidden and white areas are visible:

``````void surf(Input IN, inout SurfaceOutput o) {
float2 newuv = TRANSFORM_TEX(IN.uv_ArmUpper, _MainTex);

fixed4 MainColor = tex2D(_MainTex, newuv);
fixed4 ArmUpperColor = tex2D(_ArmUpper, IN.uv_ArmUpper);

}
``````

The mask is perfect square. It begins at 0,0 and ends at 256,256 (Full image is 512x512):

How can I avoid using this image and send in the data 0,0 - 256,256 as a “Mask” parameter ?

UVs are normalised arent they? I think between 0 and 1 but you would have to double check that.

If they are then your logic is just

``````if(coord.x <= 0.5 && coord.y <= 0.5)
{
// In white square
}
else
{
// In black part
}
``````

A simple mask like this can just be done by checking if the UV coordinate is within the desired range;

``````//This will be 1 if the UV is within the range of [min,max] and 0 otherwise
float getMask (float2 uv, float2 min, float2 max)
{
return uv.x >= min.x && uv.x <= max.x && uv.y >= min.y && uv.y <= max.y;

//Alternatively, a faster way of doing the above
return all (abs (uv - min) <= max);
}

...

half4 MainColor = tex2D (_MainTex, newuv);
half4 ArmUpperColor = tex2D (_ArmUpper, IN.uv_ArmUpper);

//UV is in a range of [0,1], so get a mask of the first quarter [0.0,0.5];