Converts one linear-light value in [0, 1] to sRGB encoding with the exact piecewise curve (the inverse of srgb_to_linear): x * 12.92 up to 0.0031308 and 1.055 * x ^ (1 / 2.4) - 0.055 above it. Values outside [0, 1] are not clamped; clamp first when the result feeds an 8-bit store.
#import "Math";
assert(abs(linear_to_srgb(0.21404114) - 0.5) < 0.00001);
x := linear_to_srgb(srgb_to_linear(0.3));
assert(abs(x - 0.3) < 0.00001);linear_to_srgb :: (x: float) -> float
Converts one linear-light value in [0, 1] to sRGB encoding with the exact piecewise curve (the inverse of srgb_to_linear): x * 12.92 up to 0.0031308 and 1.055 * x ^ (1 / 2.4) - 0.055 above it. Values outside [0, 1] are not clamped; clamp first when the result feeds an 8-bit store.
Parameters
- x: float
Returns
- float
#import "Math";
assert(abs(linear_to_srgb(0.21404114) - 0.5) < 0.00001);
x := linear_to_srgb(srgb_to_linear(0.3));
assert(abs(x - 0.3) < 0.00001);linear_to_srgb :: (c: Vector3) -> Vector3
The Vector3 form converts the three color channels, each as the scalar form does.
Parameters
- c: Vector3
Returns
linear_to_srgb :: (c: Vector4) -> Vector4
The Vector4 form converts the red, green and blue channels and leaves alpha (w) untouched.
Parameters
- c: Vector4