Skip to content

Documentation / @ripl/3d / composeSurfaceColor

Function: composeSurfaceColor() ​

composeSurfaceColor(baseColor, illumination, fog?, distance?): string

Defined in: 3d/src/core/shading.ts:299

Composes a shaded CSS colour from a surface's base colour and the light reaching it.

With no additive term this is exactly round(channel * brightness) — the expression the single-light model used — so an unlit-by-anything-new scene keeps its original pixels.

Parameters ​

ParameterTypeDefault valueDescription
baseColorColorRGBAundefinedThe surface's own colour, in 0–255 channels.
illuminationSurfaceIlluminationundefinedThe light arriving at the surface.
fog?ResolvedFog | nullundefinedThe resolved fog to blend towards, or null for none.
distance?number0Distance from the camera to the surface, used only when fog is given.

Returns ​

string

The shaded colour as a CSS rgba() string.