Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: onerain88 on June 15, 2016, 05:59:46 AM

Title: Can UIAtlas's material take multiple textures?
Post by: onerain88 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?
Title: Re: Can UIAtlas's material take multiple textures?
Post by: ArenMook 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);
Title: Re: Can UIAtlas's material take multiple textures?
Post by: onerain88 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?
Title: Re: Can UIAtlas's material take multiple textures?
Post by: onerain88 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.
Title: Re: Can UIAtlas's material take multiple textures?
Post by: ArenMook 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);
Title: Re: Can UIAtlas's material take multiple textures?
Post by: onerain88 on June 16, 2016, 05:25:38 AM
I print the "_AlphaTex", it's wrong, why?
Title: Re: Can UIAtlas's material take multiple textures?
Post by: ArenMook on June 18, 2016, 04:56:23 AM
So find out what material it is... Print its name for example.