Author Topic: UILabel custom material issue  (Read 7042 times)

Real World

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 15
    • View Profile
UILabel custom material issue
« on: January 29, 2015, 11:10:06 AM »
I'm trying to render a UILabel using my 3D camera. All the objects in our 3D world have a custom shader that modifies our vertices (http://forum.unity3d.com/threads/curved-world-screen-space-curvature-shader.281186/) so my label is currently rendering in the wrong place. I've written a custom curved world shader that renders the font correctly but each of the characters in my label are displaying as a black rectangle.

If I apply my material to a quad it renders the way I would expect

I've even tried modifying my shader to render every pixel as magenta. This displays ok on the quad again but the UILabel remains black.  Any ideas what I may have done wrong?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel custom material issue
« Reply #1 on: January 29, 2015, 01:03:16 PM »
Start by examining the shaders that come with NGUI. Unlit/Transparent Colored is a very simple shader that is a good starting point. Most of NGUI's shaders are unlit -- they are not affected by lights.

Real World

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: UILabel custom material issue
« Reply #2 on: February 05, 2015, 12:33:56 PM »
I've tried stripping my shader right back to something impossibly simple and also tried using the shader you suggested on my material and I still get the black boxes. As I said, it renders correctly on other geometry, just not on a UILabel.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel custom material issue
« Reply #3 on: February 05, 2015, 01:08:36 PM »
Well, post your shader then. Without it it's all guesswork.

Real World

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: UILabel custom material issue
« Reply #4 on: February 06, 2015, 04:13:27 AM »
OK I found the problem. Though I'm not sure why its the problem.
Curved World has two shaders, one is a "Global" shader and inherits loads of properties, the other is not. The actual shader code is irrelevant but the shader name is causing the problem. The shader that doesnt work is

  1. Shader "Hidden/VacuumShaders/Curved World/Custom/3D NGUI Font"
  2. {

and lives in VacuumShaders\Curved World\Shaders\Custom\3D NGUI Font_Global.shader

I've copied the exact same shader code into another shader file in the exact same file location but with the name

  1. Shader "VacuumShaders/Curved World/Custom/3D NGUI Font"
  2. {

at VacuumShaders\Curved World\Shaders\Custom\3D NGUI Font.shader

and it just works. I cannot explain why this works but the "global" shader does not.