cybereality
Just for fun, here's the least expensive way I could think of:
COLOR.a = 1.0 - length(floor(UV));
On the second thought maybe it's not least expensive but it certainly is the shortest.
Here's the one that might actually be though:
COLOR.a = float(!any(bvec2(floor(UV))));
EDIT: Missed the obvious one. This is probably the fastest way:
COLOR.a = 1.0 - dot(floor(UV), floor(UV));
Double call to floor will be optimized by the compiler. I didn't want to use a temp variable so it stays an oneliner.
Sorry, got a little bit obsessed 😃.
To avoid confusion - all of the methods suggested in this thread are ok to use.