simvx.core.colour

Backend-agnostic sRGB colour-space conversion helpers.

Pure-numpy implementations of the exact piecewise sRGB electro-optical transfer function (EOTF) and its inverse. They live in core (no rendering deps) so the Vulkan desktop backend and the WebGPU web runtime decode constant material colours identically, matching the hardware sRGB texture decode bit-for-bit.

Use these for COLOUR inputs (albedo / base-colour, emissive). Data maps (normal, metallic-roughness, ambient occlusion) carry no colour and must stay linear.

The piecewise curve (not the pow(2.2) approximation) is required so a flat constant colour matches a same-valued sRGB-decoded texture sample exactly.

Module Contents

Functions

srgb_to_linear

Decode sRGB-encoded values in [0, 1] to linear light (exact piecewise EOTF).

linear_to_srgb

Encode linear-light values in [0, 1] to sRGB (exact piecewise inverse EOTF).

srgb_to_linear_rgb

Decode the RGB channels of an (R, G, B[, A]) tuple, leaving any 4th component as-is.

Data

API

simvx.core.colour.__all__

[‘srgb_to_linear’, ‘linear_to_srgb’, ‘srgb_to_linear_rgb’]

simvx.core.colour.srgb_to_linear(c: numpy.ndarray | float) numpy.ndarray | float[source]

Decode sRGB-encoded values in [0, 1] to linear light (exact piecewise EOTF).

Scalar in / scalar out, or numpy array in / numpy array out (element-wise).

simvx.core.colour.linear_to_srgb(c: numpy.ndarray | float) numpy.ndarray | float[source]

Encode linear-light values in [0, 1] to sRGB (exact piecewise inverse EOTF).

simvx.core.colour.srgb_to_linear_rgb(colour: tuple[float, ...]) tuple[float, ...][source]

Decode the RGB channels of an (R, G, B[, A]) tuple, leaving any 4th component as-is.

The 4th component is alpha (linear) for albedo or emissive intensity for emissive packing: neither is a colour and both pass through untouched.