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?