Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Different texture painting behaviour on windows and mac...

Discussion in 'Scripting' started by luisanton, Apr 10, 2015.

  1. luisanton

    luisanton

    Joined:
    Aug 25, 2009
    Posts:
    325
    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:

    Code (CSharp):
    1.        int textureSize = Mathf.CeilToInt(Mathf.Sqrt(triangles.Length / 3));
    2.  
    3.         Texture2D newTexture = new Texture2D(textureSize, textureSize, TextureFormat.RGBA32, false);
    4.         newTexture.filterMode = FilterMode.Point;
    5.         newTexture.wrapMode = TextureWrapMode.Clamp;
    6.  
    7.         for (int i = 0; i < triangles.Length; i += 3) {
    8.             int triangle = i / 3;
    9.             int px = triangle % textureSize;
    10.             int py = triangle / textureSize;
    11.  
    12.             float u = (float)px / (float)textureSize;
    13.             float v = (float)py / (float)textureSize;
    14.  
    15.             uv[i] = uv[i+1] = uv[i+2] = new Vector2(u, v);
    16.  
    17.             newTexture.SetPixel(px, py, GetTriangleColor(planetoid, triangles[i], triangles[i + 1], triangles[i + 2]));
    18.  
    19.         }
    20.         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?

    Captura de pantalla 2015-04-10 a las 17.07.48.png
     
  2. luisanton

    luisanton

    Joined:
    Aug 25, 2009
    Posts:
    325
    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.
     
    Last edited: Apr 10, 2015
  3. luisanton

    luisanton

    Joined:
    Aug 25, 2009
    Posts:
    325
    Hoho... it doesn't work on my wife's mac. Could it be related to the graphic card? Nvidia/ATI issues? :m
     
  4. DearUnityPleaseAddSerializableDictionaries

    DearUnityPleaseAddSerializableDictionaries

    Joined:
    Sep 12, 2014
    Posts:
    135
    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".