I am creating a texture in code, and setting the values. For some reason, I don’t know, the pixels drawn are blurred. What is going on?
public Texture2D texture;
Color32[] outputPixels;
void Start()
{
texture = new Texture2D(320, 240, TextureFormat.ARGB32, false);
texture.wrapMode = TextureWrapMode.Clamp;
texture.filterMode = FilterMode.Point;
texture.anisoLevel = 1;
texture.mipMapBias = -.5f;
renderer.material.mainTexture = texture;
outputPixels = new Color32[320*240];
for (int y = 240 - 1; y >= 0; --y)
{
int outputIndex = y * 320;
for (int x = 0; x < 320; ++x, srcIndex ++, ++outputIndex)
{
// set every 8th column white, otherwise black
outputPixels[outputIndex] = ((x & 7) == 7) ? Color.white : Color.black;
outputPixels[outputIndex].a = 1;
}
}
texture.SetPixels32(outputPixels);
texture.Apply();
}
I expect sharp white vertical lines every 8 pixels. I get grayness. Like antialiasing, but I don’t know now to disable that??? Texture is applied to material with standard scale and offset. Could it have something to do with it not being power-of-two sized?
UPDATE: It does seem to be related to power-of-two. I changed it to 512x256 and the lines are sharp. HOWEVER this does not solve my problem, I need a non-power-of-two size!!