Srgb module

srgb_to_linear_fast

procedure3 overloadsSource

A faster srgb_to_linear for values in [0, 1], using a lookup table instead of pow. Off by less than 0.002.

Example↗
#import "Math";
assert(abs(srgb_to_linear_fast(0.5) - srgb_to_linear(0.5)) < 0.002);
srgb_to_linear_fast :: (x: float) -> float

Parameters

x: float

Returns

float
srgb_to_linear_fast :: (c: Vector3) -> Vector3

Converts the red, green and blue channels of c.

Parameters

Returns

Example↗
#import "Math";
linear := srgb_to_linear_fast(xyz(0.5, 0, 1));
assert(abs(linear.x - 0.214) < 0.002);
srgb_to_linear_fast :: (c: Vector4) -> Vector4

Converts the red, green and blue channels of c and leaves alpha as it is.

Parameters

Returns

Example↗
#import "Math";
linear := srgb_to_linear_fast(xyzw(0.5, 0, 1, 0.3));
assert(abs(linear.x - 0.214) < 0.002 && linear.w == 0.3);

See also