uniform half4 colorGreen, colorRed; half4 main(float2 coords) { float4 value = colorGreen.gggg * 2.5; float4 whole, fraction; bool4 ok; // 2.5 equals 2 + 0.5. fraction.x = modf(value.x, whole.x); ok.x = whole.x == 2 && fraction.x == 0.5; fraction.xy = modf(value.xy, whole.xy); ok.y = whole.y == 2 && fraction.y == 0.5; fraction.xyz = modf(value.xyz, whole.xyz); ok.z = whole.z == 2 && fraction.z == 0.5; fraction.xyzw = modf(value.xyzw, whole.xyzw); ok.w = whole.w == 2 && fraction.w == 0.5; return all(ok) ? colorGreen : colorRed; }