Maths · function

srgbColor

A colour picked by eye — on a screen, in a paint program, as a CSS colour — as the linear value the renderer lights, blends, fogs and grades: each channel through the sRGB curve, which the default outputTransform, 'srgb', applies the other way at the end, so a colour drawn as it is, a sky, a clear or a surface lit at exactly 1, comes out as the colour picked.

Explained in Coordinates and units.

function srgbColor(r: number, g: number, b: number): Vec3
import { srgbColor } from '@driftengine/core';

Parameters

ParameterTypeDescription
rnumber
gnumber
bnumber

In depth

Why a colour needs it: everything the renderer draws is linear and encoded at the end, so a colour typed as it looks comes out too light — a brown picked as (0.55, 0.3, 0.15) draws as tan. What it gives up: nothing at the colour picked. What would make it wrong is a number that is an amount rather than a look: a light's intensity, a multiplier, a strength, which are linear already. Allocates, so it is for building a world rather than for a frame.