A faster linear_to_srgb for values in [0, 1]: a binary search over the same 64-segment table, inverted by linear interpolation, so there is no pow call at run time. The error is below about 0.003 in the encoded result. Inputs of 1 or more fall back to the exact curve, and the linear segment below 0.0031308 is exact.
#import "Math";
x := linear_to_srgb_fast(0.5);
assert(abs(x - linear_to_srgb(0.5)) < 0.003);linear_to_srgb_fast :: (x: float) -> float
A faster linear_to_srgb for values in [0, 1]: a binary search over the same 64-segment table, inverted by linear interpolation, so there is no pow call at run time. The error is below about 0.003 in the encoded result. Inputs of 1 or more fall back to the exact curve, and the linear segment below 0.0031308 is exact.
Parameters
- x: float
Returns
- float
#import "Math";
x := linear_to_srgb_fast(0.5);
assert(abs(x - linear_to_srgb(0.5)) < 0.003);linear_to_srgb_fast :: (c: Vector3) -> Vector3
The Vector3 form converts the three color channels, each as the scalar form does.
Parameters
- c: Vector3
Returns
linear_to_srgb_fast :: (c: Vector4) -> Vector4
The Vector4 form converts the red, green and blue channels and leaves alpha (w) untouched.
Parameters
- c: Vector4