Author Topic: Can UIAtlas's material take multiple textures?  (Read 2864 times)

onerain88

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Can UIAtlas's material take multiple textures?
« on: June 15, 2016, 05:59:46 AM »
In android platform, etc1 is avaliable compress format, but etc1 has no alpha channel.
I wanna use a etc1 rgb texture for maintexture, and a etc1 alpha texture for "AlphaTexture".
I write a shader like Transport Colored.shader, there are two textures(MainTexture and AlphaTexture), but when I run, I found that it does not work. Shader's properties MainTexture and AlphaTexture are same, they are MainTexture's texture.
How should I do?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Can UIAtlas's material take multiple textures?
« Reply #1 on: June 16, 2016, 04:00:36 AM »
You specify what material the atlas uses. NGUI will use this material, and it will not try to change the texture within. In fact, if you try to set UIWidget's mainTexture, you will get an exception because it's not allowed. So all I can suggest is check your shader.

The only place I can suggest checking besides your own material / shader code, is UIPanel line 1363 where the draw call gets created:
  1. dc = UIDrawCall.Create(this, mat, tex, sdr);

onerain88

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Can UIAtlas's material take multiple textures?
« Reply #2 on: June 16, 2016, 04:25:50 AM »
Thank you for your reply.
I found UIDrawCall.Create(this, mat, tex, sdr),there is only one texture, but I need two texture (one for MainTexture, another for AlphaTexture).
Should I need modify the API?

onerain88

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Can UIAtlas's material take multiple textures?
« Reply #3 on: June 16, 2016, 04:35:45 AM »
When I use Frame Debug Tool, I found the _MainTex and _AlphaTex are the same texture resource. But the material is different texture resources.
I grap the image.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Can UIAtlas's material take multiple textures?
« Reply #4 on: June 16, 2016, 04:42:47 AM »
Thank you for your reply.
I found UIDrawCall.Create(this, mat, tex, sdr),there is only one texture, but I need two texture (one for MainTexture, another for AlphaTexture).
Should I need modify the API?
No need, the material gets copied. The main texture doesn't even need to be passed in most cases. I can only suggest adding Debug.Log statements to check the material's textures, like:
  1. Debug.Log(mat.GetTexture("_AlphaTex").name);

onerain88

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Can UIAtlas's material take multiple textures?
« Reply #5 on: June 16, 2016, 05:25:38 AM »
I print the "_AlphaTex", it's wrong, why?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Can UIAtlas's material take multiple textures?
« Reply #6 on: June 18, 2016, 04:56:23 AM »
So find out what material it is... Print its name for example.