Converts one sRGB-encoded value in [0, 1] to linear light with the exact piecewise sRGB curve: a straight segment x / 12.92 up to 0.04045 and ((x + 0.055) / 1.055) ^ 2.4 above it. 0 gives 0 and 1 gives 1. Values outside [0, 1] are not clamped: the curve is evaluated as written, so a negative input stays negative and a large one is extrapolated.
#import "Math";
assert(abs(srgb_to_linear(0.5) - 0.21404114) < 0.00001);
assert(srgb_to_linear(0.0) == 0 && abs(srgb_to_linear(1.0) - 1) < 0.00001);srgb_to_linear :: (x: float) -> float
Converts one sRGB-encoded value in [0, 1] to linear light with the exact piecewise sRGB curve: a straight segment x / 12.92 up to 0.04045 and ((x + 0.055) / 1.055) ^ 2.4 above it. 0 gives 0 and 1 gives 1. Values outside [0, 1] are not clamped: the curve is evaluated as written, so a negative input stays negative and a large one is extrapolated.
Parameters
- x: float
Returns
- float
#import "Math";
assert(abs(srgb_to_linear(0.5) - 0.21404114) < 0.00001);
assert(srgb_to_linear(0.0) == 0 && abs(srgb_to_linear(1.0) - 1) < 0.00001);srgb_to_linear :: (c: Vector3) -> Vector3
The Vector3 form converts the three color channels, each as the scalar form does.
Parameters
- c: Vector3
Returns
srgb_to_linear :: (c: Vector4) -> Vector4
The Vector4 form converts the red, green and blue channels and leaves alpha (w) untouched.
Parameters
- c: Vector4