Home Technical Talk

Converting sRGB to linear color space in Photoshop?

Mark Skovrup
polycounter lvl 6
Offline / Send Message
Pinned
Mark Skovrup polycounter lvl 6

Im working on a game and we just changed the Unity engine to run with linear color space. I am usually making textures in 8bit sRGB.

 

I've heard that It turns to linear color if I just change it to 32 bit. however It seems impossible to work with, as  a lot of wrong stuff is going on on the texture when doing it, Some areas and colors completely change and the texture doesnt look like the original at all. There must be a better way of doing this?

Replies

  • LMP
    Options
    Offline / Send Message
    LMP polycounter lvl 13
    When you're working in sRGB, to achieve a Linear 50% you'll want to use about 70% grey

    70% sRGB = 50% LInear or so.
  • Mark Skovrup
    Options
    Offline / Send Message
    Mark Skovrup polycounter lvl 6
    And how would I do that? :) some kind of grey overlay?
  • Farfarer
    Options
    Offline / Send Message
    In Unity, change the texture's mode to Advanced and tick Bypass sRGB Sampling?
  • ngw
    Options
    Offline / Send Message
    ngw polycounter lvl 5
    the textures will be gamma corrected into linear space at the necessary shader points in Unity. There's nothing special you need to do in Photoshop to facilitate this. 
  • svv3d
  • ActionDawg
    Options
    Offline / Send Message
    ActionDawg greentooth
    LMP said:
    When you're working in sRGB, to achieve a Linear 50% you'll want to use about 70% grey

    70% sRGB = 50% LInear or so.
    This doesn't really help answer anything about gamma. It is x^1/2.2 to go from linear to gamma and x^2.2 for the reverse. Throwing magic numbers at someone who doesn't understand gamma will only hurt them.
    ngw said:
    the textures will be gamma corrected into linear space at the necessary shader points in Unity. There's nothing special you need to do in Photoshop to facilitate this. 
    The first part of this isn't necessarily true, though the latter part is. My own mobile Burley-GGX shader required me to manually control gamma correction, because mobile devices don't or didn't support Unity's internal gamma correction. I created a tonemapping manager with an option for the user to toggle in shader gamma correction, or detect it from the Unity settings (which was very buggy).

    @ the OP, you need to manage gamma in Unity for what platform you are working not just for the texture settings but for the project settings as well. If you do need to do gamma correction in Photoshop for some reason (don't do this unless you really know what you're doing)  you can find a gamma control under "Exposure". Again the transformation is 1/2.2 or 2.2.

    I will also add that linearizing sRGB textures in Photoshop will reduce the quality of your textures! It's all around a bad idea.
  • troublemaker
    Options
    Offline / Send Message
    troublemaker polycounter lvl 7
    For anyone new to the idea of linear space lighting, this post could give a good introduction.

  • Wolthera
    Options
    Offline / Send Message
    Wolthera polycounter lvl 5
    will also add that linearizing sRGB textures in Photoshop will reduce the quality of your textures! It's all around a bad idea.
    Not necessarily true. Rather, you need absolutely 16bit minimum to have no visible banding and data-loss for linear sRGB.

    For the OP. It could be worth it to take a linear icc profile(Elle Stone has a lovely set of free to use icc profiles) and convert to that.

    However, game engines like Unity aren't smart enough to read icc profiles. A proper colour management system is a bit too complicated for most engine designers, so they mostly keep themselves to sRGB and Linear. DCC apps like Maya and Blender have OCIO, which isn't icc compatible and generally doesn't tag files but assumes they are linear, and also has a few more space options.

    That means that you need to tell Unity whether something is linear or not, which in turn means you don't have to do that in Photoshop. So based on this...

    1. Anything that is you painting with colors, so in a PBR workflow, the diffuse/albedo need to have 'Bypass sRGB sampling' turned OFF.(Mipmapping in linear space can be useful here though, the colors get out a little brighter and prettier for algorithms in linear space.)
    2. Anything that is you painting with numbers, such as Heightmaps, Glossiness maps, Normal maps, Exr files, Literally anything else in a PBR workflow that has you consult a physical material sheet, needs "
    Bypass sRGB sampling" turned ON.

    The logic is that you are telling Unity to NOT be doing color management on the later, because they are NOT colors, but numbers.

    Disclaimer: I have never used Unity, but I am the dev dealing with Krita's color management. I hope this helps.
  • ActionDawg
    Options
    Offline / Send Message
    ActionDawg greentooth
    I intentionally ignored 16 bit per channel textures for a few reasons: Firstly he mentioned using 8 bit per channel. Afaik Unity doesn't support them at all unless 5 added this recently, but even still it's not a logical path to take for regular texturing in any engine. The gains you get for anything but the normal map are negligible, and compression on the engine's side would kill a linearized sRGB texture from Photoshop.
  • Wolthera
    Options
    Offline / Send Message
    Wolthera polycounter lvl 5
    Ah! Alright. I assumed that noone would allow him to have anything more than 8 bit in the final product anyway, at the same time, there's so much misinformation on color management that abstracting can be dangerous, so hence why I expanded upon it. :)

    In general, just let Unity handle the conversion.
Sign In or Register to comment.