Author Topic: Materials turned Pink when switching platforms  (Read 7355 times)

eyeofhorus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Materials turned Pink when switching platforms
« on: April 06, 2017, 10:25:49 AM »
Unity 5.4.1
NGUI 3.11.2

Hello, I started building a UI on iOS platform, then I switched to Mac for testing.
After switching to Mac, I turned off Auto Graphics API for Mac, and selected OpenGL2 as preferred graphic.

Then my all materials turned pink. And I got some shader errors.
I tried changing the shader on my atlas material but nothings changed.

I will need to switch between platforms for testing.

How can I fix this and avoid it?

eyeofhorus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Materials turned Pink when switching platforms
« Reply #1 on: April 06, 2017, 10:37:13 AM »
Somehow I found that all the materials of the UI elements are lost

After I assign Sprites-Default to the Material, the pink is gone.

So the question is, how can I avoid this when I switch platform? thanks for the help.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Materials turned Pink when switching platforms
« Reply #2 on: April 07, 2017, 06:15:38 PM »
Obvious question: why are you forcing OpenGL2? Also "some shader errors" doesn't exactly tell me much :P

Also... "started building a UI on iOS platform" -- iOS?

eyeofhorus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Materials turned Pink when switching platforms
« Reply #3 on: April 09, 2017, 06:57:58 AM »
Hello,

Thanks for getting back, I'm using a third party face recognition framework which requires GL2 to display on MacOS, if I use GLCore the textures will not render correctly from the framework.

Using GL2 is only for the sake of testing the app on desktop. We wanted to save some time instead of building into the iPad device every time.

For the shaders error, it shows as below screen shot. It seems there are some repeated definitions.




ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Materials turned Pink when switching platforms
« Reply #4 on: April 14, 2017, 03:04:13 PM »
Those are Unity 5.6 auto-upgrade fail errors. I'm attaching a zip with all the NGUI's shaders that auto-upgraded properly when I updated to 5.6.

eyeofhorus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Materials turned Pink when switching platforms
« Reply #5 on: April 15, 2017, 03:30:20 AM »
Does it work if i'm on 5.4?

eyeofhorus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Materials turned Pink when switching platforms
« Reply #6 on: April 16, 2017, 07:31:18 AM »
I replaced the shaders with those you attached, but I'm still getting error in "Unlit - Text":

Shader error in 'Unlit/Text': '' : 'UNITY_VERTEX_OUTPUT_STEREO' already defined at line 40 (on opengl)

Compiling Vertex program
Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING SHADER_API_DESKTOP


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Materials turned Pink when switching platforms
« Reply #7 on: April 22, 2017, 11:17:29 AM »
Have you tried showing the generated code and seeing what Unity puts in there? It might help track down the issue. Also, is this on Unity 5.4? If so, I am guessing "UNITY_VERTEX_INPUT_INSTANCE_ID" is not defined on 5.4. the compatibility portion relies on that define. You can just remove the entire "Unity 4 compatibility" section of these shaders to get them to work on 5.4. Remove this entire section:
  1.                         // Unity 4 compatibility
  2.                         #ifndef UNITY_VERTEX_INPUT_INSTANCE_ID
  3.                         #define UNITY_VERTEX_INPUT_INSTANCE_ID
  4.                         #define UNITY_VERTEX_OUTPUT_STEREO
  5.                         #define UNITY_SETUP_INSTANCE_ID(v)
  6.                         #define UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(i)
  7.                         #define UnityObjectToClipPos(v) UnityObjectToClipPos(v)
  8.                         #endif