<sk-tonemap>

← prev index next →

Shades a surface by how much light it receives — mapping full shadow to one color and full light to another through a referenced color-map — the way to author non-photographic, illustrative lighting instead of physically-fixed shading.

Remarks

This is the concrete member of the AbstractTonemap family: like every tonemap it turns the lighting parameter (0 = full shadow, 1 = full light) into a color, so shading is authored rather than physically determined. It supplies that light-driven t; the ColorMap it names turns t into the pixel color; and an optional field can restrict where the tonemap applies.

Key attributes. color-map names the color-map to look up — it is REQUIRED, and a tonemap with no resolvable color-map is inert (renders nothing). field is an optional applicability mask: where its weight is 1 the tonemap fully applies, and where its weight is 0 it drops out to the material's effective base color shaded by light alone (without the color-map), so a field can fade the illustrative shading in over part of a surface. The color-map's own field, the tonemap's field, and the base-color compositing are each applied exactly once — nothing is double-counted.

Driver remap. A tonemap carries its OWN remap-curve that reshapes the light parameter t BEFORE it reaches the hosted color-map — inverse:linear flips a screen so light ink grows toward the lit side. This composes with any remap the color-map itself carries (t_map = mapCurve(driverCurve(t))), so the two are independent stages: the tonemap's driver remap reshapes what the color-map is asked to look up, and the color-map's remap reshapes its own response. Both the curve VALUES and a remap-phase scalar (which slides the lookup horizontally, remap(wrap(t − phase)), applied after inversion) are animatable and data-only; remap-phase on the tonemap translates the DRIVER stage, while remap-phase on the inner color-map translates the MAP stage, and the two compose.

Related. The color-map it drives is any member of the color-map family — sk-ramp-color-map (built from sk-color-stop children), sk-composite-color-map, or a dither map such as sk-halftone-dither-color-map. A material selects a tonemap with tonemap="#id" (see sk-plain-material); for a base color that varies by space rather than by light, its spatial counterpart is the ColorSource family.

Serve these docs to run the live example. WebGPU needs a secure context — open this page via grunt serve rather than double-clicking the file. The Markup tab works from disk.

Attributes

AttributeTypeDefaultDescription
remap-curveanimatable <remap-curve> Optional DRIVER remap curve: reshapes the tone value handed to the
remap-phaseanimatable <number> 0 Horizontal driver remap phase — an animatable scalar that translates the
id <id> The element's unique identifier — the standard HTML global id attribute.
color-maprequired <id-ref> The referenced color-map, or null when unresolved. Setting it imperatively reference by id
fieldanimatable <id-ref> Gets the optional field that modulates this tonemap's weight per-fragment. reference by id