I have recently converted my textures and vertex coloring to sRGB through external scripts. However, I have a lot of manual setColor, setColorScale, etc. calls that are done at runtime.
How would I go about switching these over to the new color space?..there’s quite a lot which is why I’m looking for an automatic way to do this–does such a way exist? If not, what would be the best steps forward?
If done correctly, this is not required since assets are created using linear space.
sRGB is displayed either on the monitor or through a post-processing effect.
In other words, you don’t need to physically convert textures, since there will be double the brightness if the user’s monitor already displays sRGB mode.
To convert an sRGB color in range 0-255 to linear floating-point, you can use this function:
from panda3d.core import decode_sRGB_float
# html color #123456
color = (
decode_sRGB_float(0x12),
decode_sRGB_float(0x34),
decode_sRGB_float(0x56),
)
If you already have them in floating point 0.0-1.0 range, you can also pass those directly to the same function; it behaves differently depending on whether you pass it an integer or floating-point number.