Author Topic: Unlit/Transparent Colored problems  (Read 11733 times)

sstublic

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 15
    • View Profile
Unlit/Transparent Colored problems
« on: June 24, 2014, 07:00:54 AM »
I've been having some weird compatibility problems with Unlit/Transparent Colored shader...what happens:

1. On one Huawei tablet device everything works EXCEPT for sprites with above shader...they just show up empty (nothing is rendered)..I've tried other unlit shaders and most seem to work, but for the project I need this one..This specific one device is not a problem, but I have no way of knowing on how many others it won't work. Device is relatively new and uses Android 4.0 +

2. So far I've checked at runtime and shader IS available and Unity reports it as supported

3. Funniest thing is that when I fiddled some more I've found that Sprites/Default shader (Unitys own sprite shader?) works perfectly fine, doing seemingly same things as Unlit/Transparent Colored, but I'd rather use the original NGUI stuff.

Please help on how to fix it and what caused it...


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unlit/Transparent Colored problems
« Reply #1 on: June 25, 2014, 04:55:12 AM »
Use GLES 2, not GLES 3.

sstublic

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 15
    • View Profile
Re: Unlit/Transparent Colored problems
« Reply #2 on: June 25, 2014, 06:53:05 AM »
I saw this being mentioned somewhere and already tried it (if you're referring to 'Force OpenGL ES 2.0' player setting)...

Doesn't help

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unlit/Transparent Colored problems
« Reply #3 on: June 25, 2014, 07:55:24 AM »
Sprites/Default is a surface shader, which is quite different. NGUI's shaders use a vertex+fragment shader combo. It's strange that it wouldn't work with the latest version of NGUI (you are using the latest, do you not?) This only happens on that one device? If that's the case, I'd suggest reporting it to Unity.

sstublic

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 15
    • View Profile
Re: Unlit/Transparent Colored problems
« Reply #4 on: June 25, 2014, 10:08:48 AM »
I am using NGUI 3.6.2

I don't know on how many devices it doesn't work, since I have access to only few of them...It's not an acceptable risk to assume it is only this one.

Since the end result is the same, is it safe to use Sprites/Default for NGUI materials until issue is resolved somehow?

Is there any other info I could provide to you which will enable you to be certain whether it's NGUI or Unity problem?

Maybe interesting info: NGUIs other shaders DO work. For example Unlit/Transparent or Unlit/Premultiplied Colored

p.s. I'm not really into shaders, but looking at the source code of Sprites/Default, it seems like a vertex/fragment shader as well. Why is it a surface shader?
« Last Edit: June 25, 2014, 10:23:00 AM by sstublic »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unlit/Transparent Colored problems
« Reply #5 on: June 26, 2014, 09:37:29 AM »
There is almost no difference between Transparent Colored and Premultiplied Colored shaders.

The differences I see are LOD level (one is 100, another is 200) and where the material properties block lies. One has it inside the SubShader section, another -- inside the Pass. I would suggest playing with the shader to see what's causing it to not work. Eliminate the differences piece by piece (there are very few of them).

Edit: I just did the elimination on my end, and in the end the only thing different between the two shaders is one has AlphaTest Off, and the other one does not. Well, and the Blend setting, of course.
« Last Edit: June 26, 2014, 09:42:37 AM by ArenMook »

sstublic

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 15
    • View Profile
Re: Unlit/Transparent Colored problems
« Reply #6 on: June 26, 2014, 09:53:14 AM »
I'll try playing with shader source to see which part is causing the problems.

If I find anything I'll let you know.

heskjdev

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: Unlit/Transparent Colored problems
« Reply #7 on: July 06, 2014, 12:33:26 PM »
I have the same problem from using this to render one of the NGUI [example 10] scene and I found that one object with the shader - Unlit/Transparent cause the disorder. I happens when it stays after a few seconds on the screen.

sstublic

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 2
  • Posts: 15
    • View Profile
Re: Unlit/Transparent Colored problems
« Reply #8 on: January 19, 2015, 05:01:01 PM »
I'm resurrecting this old thread because the above problem persists.

I was hoping new versions of Unity/NGUI would somehow resolve it, but they didn't.

I've found out which part of the shader code (by method of elimination) is causing the problem: 'Offset -1, -1'
This line is not present in Sprites/Default Unity shader and if removed from Unlit/Transparent Colored, the problem resolves.
So to recap:

* On Huawei Mediapad 7 Lite Unlit/Transparent Colored isn't rendering anything, I just get blank camera fill
* If I remove 'Offset -1, -1' from the shader code, everything works perfectly

1. Do you have any idea why this line would be a problem for some devices?

2. Am I safe to go without it? I see no changes in my UI, should I expect any problems if I remove this line?

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Unlit/Transparent Colored problems
« Reply #9 on: January 20, 2015, 09:42:29 PM »
You're safe to remove that line. It's there to eliminate z-fighting for cases where you use a 3D UI and place a UI element on top of something like a wall. No idea why it would cause an issue on that device, but if keeping it out helps, do it.