Sometimes you (or rather the user) is bringing in a texture at runtime that you have no control over the authoring up. In which case, if the image has alpha you are going to have to get it in the right format so it looks correct. To wit, I submit the following extension to the Texture2D class which handles this:
public static class Texture2DExtensions
{
public static void PreMultiplyAlpha(this Texture2D texture)
{
// Check if the texture has an alpha channel
if (texture.format == TextureFormat.Alpha8 ||
texture.format == TextureFormat.ARGB4444 ||
texture.format == TextureFormat.RGBA32 ||
texture.format == TextureFormat.RGBA4444 ||
texture.format == TextureFormat.RGBAFloat ||
texture.format == TextureFormat.RGBAHalf)
{
// Get the pixel data of the texture
Color[] pixels = texture.GetPixels();
// Pre-multiply the alpha values of the pixels
for (int i = 0; i < pixels.Length; i++)
{
pixels[i] = new Color(
pixels[i].r * pixels[i].a,
pixels[i].g * pixels[i].a,
pixels[i].b * pixels[i].a,
pixels[i].a
);
}
// Set the pixel data of the texture
texture.SetPixels(pixels);
texture.Apply();
}
}
}
Given Noesis' insistence on pre-multiplied Alpha, and Unity's insistence on not having pre-multiplied Alpha... might be good to have this in the Noesis API somewhere (if such a thing doesn't already exist).
David