Search Unity

Image Atlas Problems

Discussion in 'iOS and tvOS' started by iktakgames, Oct 11, 2013.

  1. iktakgames

    iktakgames

    Joined:
    Sep 5, 2012
    Posts:
    39
    Im having problems with image atlas , im trying this for reduce draw calls.
    i have a 15x10 squares with image each, all have the same two materials , a lot of draw calls.
    I put all the images in the same big image, i have a function that getme the offset and escale with and id of the image,
    1. If i try to do this:
    Code (csharp):
    1.                     ObjetosTiles[x+y*VisibleAncho].renderer.sharedMaterial = TexturaTotalMaterial;
    2.                     Vector2[] VectoresTexturas=SetSpriteAnimation(9 ,11 ,TileReal.Tipo );
    3.                     ObjetosTiles[x+y*VisibleAncho].renderer.sharedMaterial.SetTextureOffset ( "_MainTex", VectoresTexturas[0] );                    ObjetosTiles[x+y*VisibleAncho].renderer.sharedMaterial.mainTextureScale = VectoresTexturas[1];
    All the images looks equl , because im switchin the offset of all.

    but if y try to do this:

    Code (csharp):
    1.                     ObjetosTiles[x+y*VisibleAncho].renderer.material= TexturaTotalMaterial;
    2.                     Vector2[] VectoresTexturas=SetSpriteAnimation(9 ,11 ,TileReal.Tipo );
    3.                     ObjetosTiles[x+y*VisibleAncho].renderer.material.SetTextureOffset ( "_MainTex", VectoresTexturas[0] );                  ObjetosTiles[x+y*VisibleAncho].renderer.material.mainTextureScale = VectoresTexturas[1];
    or anything like this, i have the same draw calls caused for all the materials are material instances.

    How to solve this?

    2.The second problem is that not match perfectly the tiles, maybe caused for the float precission? how to solve this?
    3.I need to materials, one for ground and one for decoration, is possible?

    Thanks
     
  2. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899