Author Topic: NGUI in linear mode at Unity5 Alpha Color not working (gamma space)  (Read 2040 times)

TMitchT

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Hi,

I have a problem with using linear mode on Unity5. NGUI UI must have a gamma space. The RGB itself is OK in the new version 3.9, but the problem is that the alpha color is not working as it should be.

Does anyone know about this problem?
If so, please let me know.

I had tried this website below...
and the RGB is working right, but the I am still having issues with the Alpha Color.
http://www.tasharen.com/forum/index.php?topic=10551.0

It will be really helpful if there is someone who can help me with this problem...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: NGUI in linear mode at Unity5 Alpha Color not working (gamma space)
« Reply #1 on: July 21, 2015, 11:41:33 AM »
Try this... change UIBasicSprite.drawingColor to this:
  1.         Color32 drawingColor
  2.         {
  3.                 get
  4.                 {
  5.                         Color colF = color;
  6.                         colF.a = finalAlpha;
  7.                         if (premultipliedAlpha) colF = NGUITools.ApplyPMA(colF);
  8.  
  9.                         if (QualitySettings.activeColorSpace == ColorSpace.Linear)
  10.                         {
  11.                                 colF.r = Mathf.GammaToLinearSpace(colF.r);
  12.                                 colF.g = Mathf.GammaToLinearSpace(colF.g);
  13.                                 colF.b = Mathf.GammaToLinearSpace(colF.b);
  14.                                 colF.a = Mathf.GammaToLinearSpace(colF.a); // <-- adding this
  15.                         }
  16.                         return colF;
  17.                 }
  18.         }
If it solves your issue, you will need to modify UILabel.OnFill the same way (~line 1771).
  1.                 if (QualitySettings.activeColorSpace == ColorSpace.Linear)
  2.                 {
  3.                         col.r = Mathf.GammaToLinearSpace(col.r);
  4.                         col.g = Mathf.GammaToLinearSpace(col.g);
  5.                         col.b = Mathf.GammaToLinearSpace(col.b);
  6.                         col.a = Mathf.GammaToLinearSpace(col.a); // <-- this here
  7.                 }