Author Topic: Linear lighting / multiple materials  (Read 1753 times)

DirtyHippy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Linear lighting / multiple materials
« on: January 12, 2015, 10:48:25 AM »
NGui 3.7.7

I have been using the linear color space for a while, and have had no problems with the two atlases I currently use, using unlit/transparent colored.  However, I recently have been using some images from a different atlas from a third party, which use unlit / premultiplied colored.

The widgets that use this widget look washed out - obviously not being corrected for the color space.  I looked in the code and noted the color space corrections in UIBasicSprite and UILabel and scoured the forums.

I've tried:

1) Changing the unlit / premultiplied colored shader to:

half4 col = tex2D(_MainTex, IN.texcoord) * IN.color;
col.rgb = pow(col.rgb,2.2);
return col;         

This resolves the issue for the most part, but it doesn't resolve it on any nested panels (like scroll views, which I have a lot of).  I.e. in scroll views, the same button that displays fine on the screen that is not on the scroll panel looks washed out inside the scroll panel.

Since the code already seems to attempt to account for this, and since my current UI works fine in linear color space (and that shader has no alterations), I figure this is the wrong thing to do.

2) I also tried reverting my change to the shader and changing the import type of the button texture in question (to test) to advanced / bypass sRGB sampling and updating the atlas. This also did not resolve it.  All of the third party textures are set to Gui textures right now anyway - which I though via the documentation accounts for color space.

So I am a bit at a loss and what is going on here.



DirtyHippy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
Re: Linear lighting / multiple materials
« Reply #1 on: January 12, 2015, 05:04:14 PM »
So I just realized that the other premultiplied colored shaders were probably for clipping or something, and I made the change there, and everything is working now.

Still not sure if this is the right solution though.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Linear lighting / multiple materials
« Reply #2 on: January 13, 2015, 03:15:08 PM »
You should ideally create a new set of shaders rather than modifying the ones that come with NGUI. This way updating NGUI won't delete your changes.