blueberrymuffin3 / osu-js

https://osu-js.pages.dev
MIT License
2 stars 1 forks source link

Confusion between sRGB and linear RGB #56

Closed blueberrymuffin3 closed 2 years ago

blueberrymuffin3 commented 2 years ago

In osu-framework, Color4 stores linear RGB colors. However Pixi.js's tint values appear to use sRGB. Opacity/alpha seems to be done in the opposite way, being gamma corrected in osu-framework, but not in PIXI.js.

To convert a color from osu-framework to PIXI.js, take each RGB component to the 1/2.2 power and use that for tint. Take the opacity to the 2.2 (NOT 1/2.2) power and use that for alpha.

I'm not sure how this affects combo colors, but at the very least these is incorrect.

I am not sure if this affect storyboard C and F commands.

blueberrymuffin3 commented 2 years ago

Useful resource on sRGB and gamma: https://blog.johnnovak.net/2016/09/21/what-every-coder-should-know-about-gamma/

blueberrymuffin3 commented 2 years ago

My formulas seem to be producing incorrect results: I calculated a color of 0xd5ecf3, very similar (probably different due to sRGB's linear section) to an online converter's #d7edf4. However, a screenshot of osu! shows the value #ddffff?

Linear value from osu-framework's Color4.LightBlue: image

Color calculated w/ simple 2.2 gamma: image

Color from screenshot (song progress bar): image

I'm not sure if some kind of filter is being applied within osu!lazer, but I can't find one.

blueberrymuffin3 commented 2 years ago

According to this formula from osu-framework, the value should be #d7edf4.

blueberrymuffin3 commented 2 years ago

The color is overridden with OsuColors.BlueLighter (#ddffff)🤦