Reply To: Question: Blender Color Strangeness

Forum Archive Question: Blender Color Strangeness Reply To: Question: Blender Color Strangeness

#69955
Shawn Blanch
Participant

    Yeah that Gamma correction is what the Shader is doing to the HEX value in order to give the same visually perception of the color that is directly being converted to over in the texture brush color.
    It’s not what the texture paint brush is doing, it is directly converting the HEX into RGB without any

    Blender Color Management: https://docs.blender.org/manual/en/latest/render/color_management.html

    From the manual: Image Color Space seems to communicate what the Texture brush is working with I think.

    On to my next question:
    How do I accurately convert from linear 0.0000-1.0000 over to a proper HEX value withoutGamma correction (i.e. should be a straight conversion).
    My problem is I have yet to find a way to EXACTLY convert the value over to the HEX value blender displays every time when using Python code.
    Brecht (one of the blender devs) used this as a conversion:

    hex(max(min(int(srgb * 255 + 0.5), 255), 0))

    sRGB is a color value from 0-1. So he multiplies it by 255 and then adds 0.5 and sets the bounds of the result to be 255 at the top (using min(result,255)) and at at the bottom (using max(result,0)). Then he converts the answer into hexidecimal using a built in Python function hex()

    I don’t seem to get the exact same HEX value every time when I randomly generate a color value though. The conversion has something off a little.