Adjust shader to vanish a texture

I achieved the desired look by doing this:

COLOR.rgb = output;
if (wave > 0.0) {
	COLOR.a = (outline_mask + grid_mask);
} else {
	COLOR.a = 0.0;
}

I know if statements are not the best in shaders, but I don’t know a different way to achieve this.