Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix sRGB encoding, missing constant. #8345

Merged
merged 1 commit into from
Mar 12, 2016
Merged

Conversation

bhouston
Copy link
Contributor

I was checking each of the encoding functions for correctness while chasing down a bug. Found a bug unrelated to what I was trying to fix.

In the current source sRGBToLinear( LinearTosRGB( color ) !== color, which is a bug. Adding this constant, which is present in the sRGB Wikipedia article and also arises if you derive LinearTosRGB from sRGBToLinear.

The bug is actually present in the example code shared with me here:

#8117 (comment)

The code linked to above should also be corrected to this, notice the addition of the * 1.055 factor:

float srgbGammaCorrect( float c ) {

    return c <= 0.0031308 ? c * 12.92 : pow( c, 0.41666 ) * 1.055 - 0.055;

}

/ping @tschw

mrdoob added a commit that referenced this pull request Mar 12, 2016
fix sRGB encoding, missing constant.
@mrdoob mrdoob merged commit e6bfff3 into mrdoob:dev Mar 12, 2016
@mrdoob
Copy link
Owner

mrdoob commented Mar 12, 2016

Thanks!

@bhouston bhouston deleted the fix_srgb_encoding branch March 14, 2016 13:45
@tschw
Copy link
Contributor

tschw commented Mar 16, 2016

Yes, that was apparently my bug - one better remain one. Sorry & thanks for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants