lygia
/v1.2.0
/color
/space
/oklab2srgb
)oklab to linear RGB https://bottosson.github.io/posts/oklab/
Use:
<vec3\vec4> oklab2srgb(<vec3|vec4> oklab)
#ifndef MAT_OKLAB2SRGB
#define MAT_OKLAB2SRGB
const mat3 OKLAB2SRGB_A = mat3(
1.0, 1.0, 1.0,
0.3963377774, -0.1055613458, -0.0894841775,
0.2158037573, -0.0638541728, -1.2914855480);
const mat3 OKLAB2SRGB_B = mat3(
4.0767245293, -1.2681437731, -0.0041119885,
-3.3072168827, 2.3098, 0.2307590544,
-0.3411344290, 1.7066093323231,-0.7034768625689);
#endif
#ifndef FNC_OKLAB2SRGB
#define FNC_OKLAB2SRGB
vec3 oklab2srgb(const in vec3 oklab) {
vec3 lms = OKLAB2SRGB_A * oklab;
return OKLAB2SRGB_B * (lms * lms * lms);
}
vec4 oklab2srgb(const in vec4 oklab) { return vec4(oklab2srgb(oklab.xyz), oklab.a); }
#endif
Use:
<float3\float4> oklab2srgb(<float3|float4> oklab)
#ifndef MAT_OKLAB2SRGB
#define MAT_OKLAB2SRGB
const float3x3 OKLAB2SRGB_A = float3x3(
1.0, 1.0, 1.0,
0.3963377774, -0.1055613458, -0.0894841775,
0.2158037573, -0.0638541728, -1.2914855480);
const float3x3 OKLAB2SRGB_B = float3x3(
4.0767245293, -1.2681437731, -0.0041119885,
-3.3072168827, 2.3098, 0.2307590544,
-0.3411344290, 1.7066093323231,-0.7034768625689);
#endif
#ifndef FNC_OKLAB2SRGB
#define FNC_OKLAB2SRGB
float3 oklab2srgb(float3 oklab) {
float3 lms = mul(OKLAB2SRGB_A, oklab);
return mul(OKLAB2SRGB_B, (lms * lms * lms));
}
float4 oklab2srgb(float4 oklab) { return float4(oklab2srgb(oklab.xyz), oklab.a); }
#endif
const OKLAB2SRGB_A : mat3x3<f32> = mat3x3<f32>(
vec3f(1.0, 1.0, 1.0),
vec3f(0.3963377774, -0.1055613458, -0.0894841775),
vec3f(0.2158037573, -0.0638541728, -1.2914855480) );
const OKLAB2SRGB_B : mat3x3<f32> = mat3x3<f32>(
vec3f(4.0767245293, -1.2681437731, -0.0041119885),
vec3f(-3.3072168827, 2.3098, 0.2307590544),
vec3f(-0.3411344290, 1.7066093323231, -0.7034768625689) );
fn oklab2srgb(oklab: vec3f) -> vec3f {
let lms = OKLAB2SRGB_A * oklab;
return OKLAB2SRGB_B * (lms * lms * lms);
}
LYGIA is dual-licensed under the Prosperity License and the Patron License for sponsors and contributors.
Sponsors and contributors are automatically added to the Patron License and they can ignore the any non-commercial rule of the Prosperity Licensed software (please take a look to the exception).
It's also possible to get a permanent comercial license hook to a single and specific version of LYGIA.
Sign up for the news letter bellow, joing the LYGIA's channel on Discord or follow the Github repository