by leguminous · 1y ago · 0 comments
Method 1.
float linear_to_srgb(float v) {
return v < 0.0031308 ? v * 12.92 : 1.055 * pow(v, 1.0 / 2.4) - 0.055;
}
vec3 linear_to_srgb(vec3 rgb) {
return vec3(linear_to_srgb(rgb.r), linear_to_srgb(rgb.g), linear_to_srgb(rgb.b));
}
Method 2: vec3 linear_to_srgb(vec3 rgb) {
bvec3 cutoff = lessThan(rgb, vec3(0.0031308));
vec3 upper = vec3(1.055) * pow(rgb, vec3(1.0 / 2.4)) - vec3(0.055);
vec3 lower = rgb * vec3(12.92);
return mix(upper, lower, cutoff);
}No comments yet.