-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
THREE.Color: added sRGB conversion methods #14332
Conversation
+1 for the clearer naming of Just to confirm here, the power of 2.4 is chosen to approximate a gamma factor of 2.2, yes? That assumption might benefit from a comment in the code and/or docs. It seems a little weird to diverge from our existing |
No, you have a misunderstanding. Have a look at the Wikipedia sRGB article, and read about the sRGB transfer function.
|
It's this bit...
...that I find non-obvious. But assuming a change to from gamma nomenclature to |
src/math/Color.js
Outdated
@@ -329,6 +329,54 @@ Object.assign( Color.prototype, { | |||
|
|||
}, | |||
|
|||
copySRGBToLinear: function ( color ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be
copySRGBToLinear: function () {
function SRGBToLinear( c ) {
return ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );
}
return function( color ) {
this.r = SRGBToLinear( color.r );
this.g = SRGBToLinear( color.g );
this.b = SRGBToLinear( color.b );
return this;
};
}()
so that it will not create function in every call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. Thanks!
r95 milestone? How about right now? |
Okay 😛 |
Thanks! |
I expect these methods will, at some point, replace
convertGammaToLinear()
, etc.