In an Android game, I have a gradient background that changes color over time. This was achieved by creating a 1x2 pixel texture in code, and stretching it over a large quad with bilinear filtering.
This all works fine in the editor, but as soon as it is viewed on an Android device, the banding is ridiculously noticeable and annoying.
Since this texture is generated in code, I cannot set the compression to "truecolor" like most other post suggest, nor can I tick the "Generate Mipmap" option.
Here is how the gradient look on the phone :
Code to generate gradient (stripped of unimportant stuff):
Texture2D gradient;
MeshRenderer render;
Color HSV1, HSV2;
Color primaryColor, secondaryColor;
render = GetComponent<MeshRenderer>();
Update() {
HSV1.x += 0.01F * Time.deltaTime;
HSV2.x = HSV1.x;
if (HSV1.x > 1)
HSV1.x = HSV1.x - 1;
if (HSV2.x > 1)
HSV2.x = HSV2.x - 1;
primaryColor = Color.HSVToRGB(HSV1.r, HSV1.g, HSV1.b + HSVdifferece);
secondaryColor = Color.HSVToRGB(HSV2.r, HSV1.g - HSVdifferece, HSV1.b - HSVdifferece);
gradient.SetPixel(0, 0, primaryColor);
gradient.SetPixel(0, 1, secondaryColor);
gradient.filterMode = FilterMode.Bilinear;
gradient.Apply();
render.material.SetTexture("_MainTex", rainbow);
}
The color banding is really obvious and annoying. How can I fix this?