Different texture painting behaviour on windows and mac...

We are creating and painting a texture with the following piece of code. Bear in mind this is not standard. It assigns to each vertex a single pixel in the texture:

       int textureSize = Mathf.CeilToInt(Mathf.Sqrt(triangles.Length / 3));

        Texture2D newTexture = new Texture2D(textureSize, textureSize, TextureFormat.RGBA32, false);
        newTexture.filterMode = FilterMode.Point;
        newTexture.wrapMode = TextureWrapMode.Clamp;

        for (int i = 0; i < triangles.Length; i += 3) {
            int triangle = i / 3;
            int px = triangle % textureSize;
            int py = triangle / textureSize;

            float u = (float)px / (float)textureSize;
            float v = (float)py / (float)textureSize;

            uv[i] = uv[i+1] = uv[i+2] = new Vector2(u, v);

            newTexture.SetPixel(px, py, GetTriangleColor(planetoid, triangles[i], triangles[i + 1], triangles[i + 2]));

        }
        newTexture.Apply();

But the resulting texture is exactly the same on both systems…

It works flawlessly on a Mac, but doesn’t work at all on a Windows machine. See the image; left side (Mac) shows all yellow triangles properly painted, but on the right side (Windows) they are scattered through the mesh.

We’ve even tried to force Unity to use OpenGL on Windows. Same result.

Any clue?

New findings

  • Android build created on Windows also shows those scattered triangles on my colleague’s phone.
  • Android build created on Mac works ok on my MotoG, but not on my colleague’s galaxy S3.

Hoho… it doesn’t work on my wife’s mac. Could it be related to the graphic card? Nvidia/ATI issues? :m

Did you find a solution? Didn’t work on my Mac either but it works on my Unity editor. It doesn’t seem to let me pass “TextureFormat.RGBA32”.