Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Linear Color Space affecting IMGUI Textures?

Discussion in 'Editor & General Support' started by shawnblais, Mar 1, 2016.

  1. shawnblais

    shawnblais

    Joined:
    Oct 11, 2012
    Posts:
    324
    We're experimenting with Linear Color Space in our game, and noticed that changing from Gamma to Linear has changed the look of our custom inspector panels.

    For example, drawing a simple texture in an editor window:
    Code (csharp):
    1.  
    2. var tex = new Texture2D(1, 1, TextureFormat.RGBA32, false);
    3. tex.SetPixel(0, 0, new Color(.4f, 0, 0, 1));
    4. tex.Apply();
    5. var rect = GUILayoutUtility.GetRect(100, 100);
    6.  GUI.DrawTexture(rect, tex);
    7.        
    Linear:


    Gamma:


    It's also affecting the embedded textures in our windows.

    Linear:

    Gamma:


    What gives? Is this expected behavior? there a way to turn it off?
     
  2. shawnblais

    shawnblais

    Joined:
    Oct 11, 2012
    Posts:
    324
  3. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,511
    I would like to know this as well.
     
  4. Member123456

    Member123456

    Joined:
    Oct 17, 2012
    Posts:
    237
    Having exact same issue. Was driving me nuts trying to figure out what messed up all the colors of my custom inspector images. Turns out it was switching to linear color space.
     
  5. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,511
    This got to be a bug?
     
  6. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,805
    Anyone solved this yet? :(
     
  7. AndrewRH

    AndrewRH

    Joined:
    Jan 24, 2012
    Posts:
    2,805
    If you're drawing in the Editor, EditorGUI.DrawTextureTransparent seems to behave with linear/srgb