-
-
Save destiny0114/f21cef16a09558d5e379f62dd2d22814 to your computer and use it in GitHub Desktop.
Revisions
-
akella created this gist
Oct 8, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,43 @@ float fixedpow(float a, float x) { return pow(abs(a), x) * sign(a); } float cbrt(float a) { return fixedpow(a, 0.3333333333); } vec3 lsrgb2oklab(vec3 c) { float l = 0.4122214708 * c.r + 0.5363325363 * c.g + 0.0514459929 * c.b; float m = 0.2119034982 * c.r + 0.6806995451 * c.g + 0.1073969566 * c.b; float s = 0.0883024619 * c.r + 0.2817188376 * c.g + 0.6299787005 * c.b; float l_ = cbrt(l); float m_ = cbrt(m); float s_ = cbrt(s); return vec3( 0.2104542553 * l_ + 0.7936177850 * m_ - 0.0040720468 * s_, 1.9779984951 * l_ - 2.4285922050 * m_ + 0.4505937099 * s_, 0.0259040371 * l_ + 0.7827717662 * m_ - 0.8086757660 * s_ ); } vec3 oklab2lsrgb(vec3 c) { float l_ = c.r + 0.3963377774 * c.g + 0.2158037573 * c.b; float m_ = c.r - 0.1055613458 * c.g - 0.0638541728 * c.b; float s_ = c.r - 0.0894841775 * c.g - 1.2914855480 * c.b; float l = l_ * l_ * l_; float m = m_ * m_ * m_; float s = s_ * s_ * s_; return vec3( 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s ); }