Status: Approved (2026-09-28), part of the v1 contract. This document, together with manifest-v1.md, is the normative rendering contract for the face lens manifest v1. The format is tagged format-v1.0.0 (engine 1) and format-v1.1.0 (engine 2, §11.8–11.12); a field-level change here needs the process in §10.9. Screen effects have their own rendering contract, effect-rendering-v1.md. Before the split this document also covered them, as lens kind 2. Those items moved there; each keeps its number here as a one-line pointer, and no number is reused, so a citation of an unchanged item still points at the same text. format-v1.1.0 (engine 2). iOS SDK 0.2.0 shipped on format-v1.0.0, which is now fixed. The animation upgrades — anchor and roll-follow tracks, custom curves, lanes, signal-driven clips (§11.8–11.12) — are additive optional fields at engine level 2 (10.9), tagged format-v1.1.0. Everything below this paragraph about "one version" is the history of format-v1.0.0. One version until the SDKs ship (history). Before an SDK shipped, every change to v1 was part of format-v1.0.0 itself: the tag was moved forward to include it. Every renderer (the editor preview's reference renderer, the iOS and Android SDKs) follows the text as tagged. The edits made after the first draft of this document are listed below so an SDK that pinned an earlier commit knows what moved. Clarifications — they pin what the first draft left open: 2.5 (no-face wording now points at 6.10), 3.7 (a sprite hidden by endBehavior: 2, then shown or played), 4.3 (a LUT grades un-premultiplied colour), 6.9 (order of events within one frame — clocks, particle emission and expiry, the start event, host events, face triggers and emission start; emission instants in whole microseconds), 7.7 (emission instants evaluated in whole microseconds, as 6.9 (1c) specifies) and 10.12 (the per-instance state list). Behaviour decisions made after the first draft — not gap-fills: each changes what the first draft literally required for some valid manifests. No SDK renderer existed when they were made (both SDK repos were at scaffold plus the format pin), so no renderer had to change. (a) Triggers start armed (6.10; 2.5 and 6.3 point at it). Under the first draft's edge wording (6.3) and 2.5's "face-signal values read as 0" without a face, a threshold: 0 trigger never fired and a signal already high on the first frame was left undefined. Now a threshold: 0 trigger fires on the frame a face is acquired or re-acquired, and a signal at or above threshold on the first frame with a face fires. (b) Moved: the flash's exclusion from shake and pulse is a screen-effect rule (effect-rendering-v1.md E8.1, E8.3). (c) Face-particle lengths are fixed at emission (7.9; 1.6 amended). The first draft's 1.6 listed particle speed, gravity and sizeScale among the lengths re-evaluated every frame. Now a particle takes W once, at emission, for every length. Added before anything shipped: keyframe animation — the optional animations list and action 6, play animation (§11, 7.11; 5.4, 6.9 steps 1a–1b, 10.6 and 10.12 amended). Like the full-face anchor (10.11) it is engine level 1: part of format-v1.0.0.
Status: Approved (2026-09-28), part of the v1 contract. This document, together with manifest-v1.md, is the normative rendering contract for the face lens manifest v1. The format is tagged format-v1.0.0 (engine 1) and format-v1.1.0 (engine 2, §11.8–11.12); a field-level change here needs the process in §10.9.
manifest-v1.md
format-v1.0.0
format-v1.1.0
Screen effects have their own rendering contract, effect-rendering-v1.md. Before the split this document also covered them, as lens kind 2. Those items moved there; each keeps its number here as a one-line pointer, and no number is reused, so a citation of an unchanged item still points at the same text.
effect-rendering-v1.md
format-v1.1.0 (engine 2). iOS SDK 0.2.0 shipped on format-v1.0.0, which is now fixed. The animation upgrades — anchor and roll-follow tracks, custom curves, lanes, signal-driven clips (§11.8–11.12) — are additive optional fields at engine level 2 (10.9), tagged format-v1.1.0. Everything below this paragraph about "one version" is the history of format-v1.0.0.
One version until the SDKs ship (history). Before an SDK shipped, every change to v1 was part of format-v1.0.0 itself: the tag was moved forward to include it. Every renderer (the editor preview's reference renderer, the iOS and Android SDKs) follows the text as tagged. The edits made after the first draft of this document are listed below so an SDK that pinned an earlier commit knows what moved.
Clarifications — they pin what the first draft left open: 2.5 (no-face wording now points at 6.10), 3.7 (a sprite hidden by endBehavior: 2, then shown or played), 4.3 (a LUT grades un-premultiplied colour), 6.9 (order of events within one frame — clocks, particle emission and expiry, the start event, host events, face triggers and emission start; emission instants in whole microseconds), 7.7 (emission instants evaluated in whole microseconds, as 6.9 (1c) specifies) and 10.12 (the per-instance state list).
endBehavior: 2
Behaviour decisions made after the first draft — not gap-fills: each changes what the first draft literally required for some valid manifests. No SDK renderer existed when they were made (both SDK repos were at scaffold plus the format pin), so no renderer had to change.
threshold: 0
threshold
speed
gravity
sizeScale
W
Added before anything shipped: keyframe animation — the optional animations list and action 6, play animation (§11, 7.11; 5.4, 6.9 steps 1a–1b, 10.6 and 10.12 amended). Like the full-face anchor (10.11) it is engine level 1: part of format-v1.0.0.
animations
manifest-v1.md defines the manifest's shape and validation. It does not say how a renderer interprets the values. The iOS SDK, the Android SDK and the editor's web preview are three independent renderers that must agree in golden tests, so every interpretation below has to be pinned once, here.
Each item carries one marker:
2026-09-28-ingevora-mirage-design.md
Both decisions below were approved as recommended, adding required fields to v1 before it is tagged (no formatVersion bump).
formatVersion
sheet.loop: false
sheet.endBehavior
spriteSheet
1
2
visible
show
play sprite
loop
offset: { x, y }
offset
transform.offset
Everything else in this document is [S] or [P]. Note that the schema is strictObject everywhere and engine levels exist only per layer type, anchor and event source, so any field added after the tag — even an optional one — makes older SDKs reject the lens with no minEngineVersion to explain why (see 10.9).
strictObject
minEngineVersion
1.1 [S] §2, §4.2, §7.2 — A face lens is drawn into the outgoing frame; the processed frame is what remote viewers receive, and the self-view shows those same processed frames.
1.2 [P] The renderer's input and output are the un-mirrored camera image, upright (the host rotates the buffer, or passes its orientation, before rendering). Mirroring for a self-view is a display transform the preview view applies after rendering; the sent frame is never mirrored. Rationale: one image space for all renderers; text on a sticker reads correctly to the people who receive the video.
1.3 [P] Image axes: origin at the top-left pixel corner, +x right, +y down, pixel units of the output frame. Pixel centres are at (i + 0.5, j + 0.5). Rationale: matches every platform's 2D image convention (Core Graphics flipped, Android Canvas, HTML canvas).
(i + 0.5, j + 0.5)
1.4 [P] "Left" and "right" in anchor names (2/3, 5/6, 8/9) are the subject's anatomical left and right. In the un-mirrored image the subject's left eye appears on the image's right. Each SDK maps its tracker's naming to this; the landmark fixtures (10.4) pin it. Rationale: trackers disagree on naming; anatomical is the only unambiguous choice.
1.5 [P] Face frame. Let EL, ER be the subject's left and right eye centres. M = (EL + ER) / 2 is the face origin. The face-frame x axis u = normalize(EL − ER) (points to image-right for an upright face); the y axis v is u rotated +90° (points down, toward the chin). Roll = atan2(u.y, u.x) in degrees: 0 for an upright face, positive when the head tilts clockwise on screen. Rationale: eye centres are the landmarks every tracker (Vision, ML Kit, MediaPipe) returns most stably.
EL
ER
M = (EL + ER) / 2
u = normalize(EL − ER)
v
u
atan2(u.y, u.x)
1.6 [P] Face width W = 2.2 × |EL − ER| in pixels (2.2 ≈ bizygomatic width ÷ inter-pupillary distance for an adult). All lengths — scale, offset, particle speed, gravity, sizeScale — are multiples of W, re-evaluated every frame for non-particle layers; particles take W once, at emission (7.9). (Amended after the first draft: decision (c) in the header.) Rationale: a face-contour width depends on each tracker's contour model and on yaw; the eye-distance proxy is identical across trackers. Foreshortening under yaw shrinks W, which is the intended 2D approximation of "follows head pose" (§5.3: v1 is 2D affine).
W = 2.2 × |EL − ER|
scale
1.7 [S] §5.3 — Engine 5 adds 3D model layers posed by the head (§12); the 2D layers stay as below. v1 layers are 2D: anchors plus affine transforms. No yaw/pitch perspective, no occlusion by the head.
1.8 [P] Sticker placement (type 2, and type 4 with placement.mode 1). The asset (or one sprite frame) is drawn with its centre at P = A + offset, width scale × W, height from the asset's aspect ratio (frame aspect for sprites).
placement.mode
P = A + offset
scale × W
followRoll: true
P = A + W·(offset.x·u + offset.y·v)
roll + rotationDeg
followRoll: false
P = A + W·(offset.x, offset.y)
rotationDeg
1.9 [P] Rotation: degrees, positive = clockwise on screen (y-down), 0 = the asset upright as authored. Applies to rotationDeg and directionDeg. directionDeg 0 = +x (right), 90 = down, −90 = up (the face-sparks fixture's −90 fires upward). Rationale: consistent with the y-down image axes; matches CSS rotate() for the web preview.
directionDeg
face-sparks
rotate()
1.10–1.12 — Moved: the overlay's space and its unit S are the screen effect contract's (effect-rendering-v1.md E1.1–E1.3).
S
1.13 [P] Gravity is a constant acceleration along +y (down) in image axes, in W/s²; negative values accelerate upward. It is never rotated by head roll. Rationale: gravity is a world direction; a particle fired straight up with speed 0.8 and gravity 1 rises 0.32 W and falls back.
W/s²
2.1 [P] Measured anchors (from landmarks, per frame):
3
4
7
2.2 [P] Derived anchors (fixed offsets in the face frame from M, in W):
M
(+x toward the subject's left, per 1.5.) Rationale: trackers have no forehead point and no ears, and their cheek points differ; fixed offsets are identical everywhere. The constants are proposals for the phase-0 spike to tune before the tag — after the tag they are contract.
2.2a [P] Full face (anchor 10) is the centre of the whole face, brows to chin, at face-frame (0, +0.15) — halfway between a hairline at about −0.55 W and the menton at about +0.86 W above/below M for an adult face. It is placed exactly like every other anchor (1.8): with scale 1 the layer is one face width W wide, height from its image's aspect, rotated by roll + rotationDeg when followRoll is on. Face particles on it spawn at that point (2.6). It is a derived anchor, not the menton-based midpoint, so it does not move when the mouth opens. The scenario packages/render/fixtures/scenarios/lens/full-face-mask.json pins it. Rationale: a mask needs the face's centre and the face's size; both are already in the face frame, so no tracker needs anything new. It is engine level 1 and part of format-v1.0.0 (added before any lens was published or any SDK shipped), so every engine-1 renderer (the SDKs' 1.0.0) implements it.
followRoll
packages/render/fixtures/scenarios/lens/full-face-mask.json
2.3 [P] Anchor positions are not smoothed by the renderer. Any landmark smoothing belongs to the SDK's tracking stage, upstream of the renderer, and is off when face data is supplied externally (§4.2 "external face data") — which is how golden tests feed faces (10.4). Rationale: smoothing filters are the first place two SDKs would diverge.
2.4 [P] One face. If several faces are detected, the lens tracks the one with the largest W; ties go to the one whose M is closest to the frame centre. The choice is re-evaluated every frame.
2.5 [P] No face. While no face is tracked: face-anchored layers (types 2, 4-mode-1, 5 emission) are not drawn / do not emit, without changing their visible state; full-frame layers (1, 3, 4-mode-2) keep drawing; already-emitted particles keep simulating; face-signal triggers are not evaluated and re-arm (6.10; behaviour decision (a) in the header).
2.6 [D2] Face particles (type 5) spawn at anchor point A + offset, rotated with the face frame exactly as a sticker offset is (1.8).
A
3.1 [P] Frames are laid out row-major from the top-left: columns = floor(sheetWidth / frameWidth), rows = floor(sheetHeight / frameHeight); frame k is the cell at column k mod columns, row floor(k / columns). Leftover pixels on the right/bottom edges are ignored.
columns = floor(sheetWidth / frameWidth)
rows = floor(sheetHeight / frameHeight)
k
k mod columns
floor(k / columns)
3.2 [P] frameCount > columns × rows is invalid, rejected where images are decoded: at upload/publish by the API, and by the SDK's validate-before-cache (§4.3 "every image actually decodes"). Issue code asset.sheet_too_small (decode-time, not in checkRules, because the manifest has no image dimensions).
frameCount > columns × rows
asset.sheet_too_small
checkRules
3.3 [D1] Frame index during playback: k = floor(tPlay × fps / 1000) where tPlay is ms since playback started (5.x). loop: true → k mod frameCount; loop: false → after frameCount − 1, the layer follows sheet.endBehavior: 1 holds on the last frame · 2 hides (visible becomes false; a later show or play sprite shows it again from frame 0, per 7.3 and 7.6).
k = floor(tPlay × fps / 1000)
tPlay
loop: true
k mod frameCount
loop: false
frameCount − 1
3.4 [P] A sprite layer that is visible but not playing (never played, e.g. autoplay: false) shows frame 0.
autoplay: false
3.5 [P] Sampling: bilinear, clamped to the frame's own cell (inset half a texel) so neighbouring frames never bleed in; no mipmaps.
3.6 [P] Type 4 with placement.mode 2 and type 3 frame overlays have no fit: type 3 is stretched to the full output frame (borders stay on every edge); type 4 mode 2 uses cover (centred, aspect preserved, overflow cropped). Rationale: a border must touch all four edges on every aspect ratio; an animation must not distort.
fit
3.7 [P] (clarification, D1 addendum) When a non-looping sprite with endBehavior: 2 passes its last frame — visible or not (a sprite hidden by an action keeps its clock, 7.2) — its playback stops and visible becomes false. A later show makes it visible showing frame 0 without playing (7.1 — show sets visible only; 3.4); a later play sprite replays it from frame 0 (7.3). The end-hide is evaluated when the sprite clock advances at the start of a frame (6.9), so a show or play sprite on the frame the sprite ends wins.
4.1 [P] Layout as already documented (64³, 8 × 8 tiles). The LUT maps sRGB-encoded input to sRGB-encoded output; no linearisation. Rationale: the authoring tools that export LUTs work in encoded values; three renderers agree trivially.
4.2 [P] Sampling is trilinear: r, g, b ∈ [0,1] map to lattice coordinates c × 63; red and green interpolate bilinearly within a tile (texel centres), blue interpolates linearly between the two neighbouring tiles.
r, g, b ∈ [0,1]
c × 63
4.3 [P] intensity blends in encoded space: out = mix(in, lut(in), intensity); alpha is untouched; the LUT asset's alpha channel is ignored. A LUT grades un-premultiplied colour: in is the pixel's straight colour, so its grade never depends on its alpha. A premultiplied renderer divides by alpha before the lookup and multiplies the result by the unchanged alpha; a pixel with alpha 0 stays as it is. (Clarification after the first draft.)
intensity
out = mix(in, lut(in), intensity)
in
4.4 [P] A LUT grades everything below it in layer order (the camera image plus lower layers) — not layers above it. Put it at index 0 to grade only the camera.
5.1 [S] §3.2 — layers[] is ordered.
layers[]
5.2 [P] Array order is back to front: index 0 is drawn first (nearest the camera image / host UI), the last layer on top.
5.3 [P] Compositing is source-over with premultiplied alpha, in sRGB-encoded space (no linear blending). PNGs are decoded as straight alpha and premultiplied once at load; every asset is treated as sRGB and embedded colour profiles / gamma chunks are ignored. Rationale: matches HTML canvas (the editor preview) and is cheap on the oldest devices (§4.4).
5.4 [P] opacity (types 2, 3) multiplies the premultiplied source. Layers without opacity (4, 5) draw at 1. An animated opacity (§11.4) multiplies the same way — for type 4 too, resting at 1; face particles keep 1.
opacity
5.5 [P] Within a particle layer, particles draw in emission order (oldest first), each as an upright quad centred on its position, width sizeScale × W, height by the asset's aspect ratio, opacity 1 for its whole life, removed when its age reaches lifetimeMs. No per-particle rotation or fade in v1.
sizeScale × W
lifetimeMs
5.6 — Moved: overlapping screen-effect instances (effect-rendering-v1.md E4.6).
6.1 [P] Face signals are scalars in [0, 1] computed per frame from the tracked face:
s
mouth.open
0.35 W
brows.raised
blink
head.tilt
smile
Rationale: each is a ratio of landmark distances, so it is scale-invariant and computable from the same injected face data in every renderer. Constants are spike-tuned before the tag and pinned by signal fixtures (10.4).
Recalibrated in format-v1.3.0 (2026-11-02): the first constants put a face at rest at brows.raised 1.0 and smile about 0.25–0.8 on real faces (the iOS lab with Vision; MediaPipe's canonical face, brow 0.19 W above the eye). Measured with the Android lab (ML Kit, a real face, 10 frames a pose): at rest the brow sits 0.195–0.212 W above the eye and the mouth corners 0.387–0.390 W apart; a broad smile spreads the corners to 0.498 W. So brows.raised now rests at 0.20 W (its 0.08 range is kept until a raised-brows measurement confirms it) and smile runs from 0.39 to 0.49 W. mouth.open, blink and head.tilt read at rest as intended and are unchanged. An SDK pinned to an earlier tag still reads the first constants.
format-v1.3.0
6.2 [P] Default threshold when omitted: 0.5 for every face signal.
6.3 [P] Face-signal triggers are edge-triggered: fire on the frame where s goes from < threshold to ≥ threshold. The arm state in 6.10 makes this exact, including the first frame and threshold: 0 (decision (a) in the header).
< threshold
≥ threshold
6.4 [P] Re-arm with hysteresis: after firing, the trigger fires again only after s has dropped below max(0, threshold − 0.1). No time-based cooldown. A lost face (2.5) re-arms. Rationale: stops one mouth-opening from firing on every jittery frame, without a hidden timer.
max(0, threshold − 0.1)
6.5 [P] A trigger fires with s measured on the frame; its actions apply to that same frame's render.
6.6 [P] Lifecycle: lens.started fires once, on the first frame processed after the lens is attached.
lens.started
6.7 [P] Host events are delivered to the attached face lens (running screen effects receive them too, effect-rendering-v1.md E5.2); they are applied at the next rendered frame. Events arriving before the lens has started or after it is detached are dropped, never queued. Events with no matching trigger are ignored.
6.8 [P] When one event matches several triggers, triggers run in array order and actions in array order within each, all before the frame renders; later actions win (show then hide in the same frame = hidden).
hide
6.9 [P] (clarification) Order within one frame. At frame time t:
t
autoplay
startMs
t_k ≤ t
t_k
Math.round
.rounded()
T = round(t × 1000)
T_0
T
T_k = T_0 + round((k × 1 000 000) / ratePerSecond)
B
T_k
emit
T_k ≤ T
X
X − B ≥ lifetimeMs × 1000
(T − B) / 1 000 000
t_k < t
t_0 = t
k = 0
All actions of steps 2–4 apply to this frame's render (6.5), and later actions win across the whole sequence; 6.8 still orders the triggers matching one event. Particles emitted by an action (7.4) are born at t.
Example: on one frame a host event hides a sprite and a mouth.open trigger shows it. The host event runs first (step 3) and the face trigger second (step 4), so the sprite is drawn.
Rationale: one fixed order is the only way two renderers agree when a host event and a face trigger touch the same layer on the same frame; pinning emission and expiry to event instants (t_k), not to frames, keeps particle pools identical at any frame rate.
6.10 [P] (behaviour decision (a) after the first draft, see the header; 2.5 / 6.3 / 6.4 addendum) Each face-signal trigger is armed or disarmed, and starts armed. On a frame with a tracked face, an armed trigger whose signal s ≥ threshold fires and disarms; a disarmed trigger re-arms when s < max(0, threshold − 0.1) (6.4). On a frame with no tracked face, face-signal triggers are not evaluated and all re-arm. This state machine is authoritative where it differs from the edge wording of 6.3 — notably a trigger with threshold: 0 fires on the frame a face is acquired or re-acquired, and not while the face is absent.
s ≥ threshold
s < max(0, threshold − 0.1)
7.1 [P] show / hide are idempotent: they set visible and nothing else. show on a visible layer and hide on a hidden layer do nothing.
7.2 [P] hide on a particle layer clears its live particles and stops continuous emission; hide on a sprite keeps its playback clock running (visibility and playback are independent).
7.3 [P] play sprite implies show, and restarts from frame 0 if already playing. Rationale: playing an invisible sprite is never the intent; restart is what "play" means on every media API. (The face-crown fixture's show + play stays valid, just redundant.)
face-crown
play
7.4 [P] emit particles implies show, then emits count particles at once. If fewer than count slots are free under maxParticles, the excess is dropped — live particles are never evicted. Rationale: deterministic and allocation-free.
emit particles
count
maxParticles
7.5 — Moved: run motion is a screen-effect action (effect-rendering-v1.md E6.5).
run motion
7.6 [P] autoplay: true (type 4) = an implicit play sprite at lens.started, without changing visible. A hidden autoplaying sprite runs its clock and appears mid-animation when shown.
autoplay: true
7.7 [P] Continuous emission runs at ratePerSecond while the layer is visible and autoEmit is true and a face is tracked. Emission times are t_k = k / ratePerSecond for k = 0, 1, 2, … measured from when emission became active (re-started at 0 on each show), evaluated in whole microseconds as 6.9 (1c) specifies. ratePerSecond: 0 never emits continuously.
ratePerSecond
autoEmit
t_k = k / ratePerSecond
ratePerSecond: 0
7.8 — Moved: burstCount is a screen-particle field (effect-rendering-v1.md E6.7).
burstCount
7.9 [P] Particle motion is evaluated in closed form, never integrated: p(t) = p0 + v0·t + ½·g·t² with t the particle's age in seconds, v0 = speed × (cos θ, sin θ) and g = (0, gravity), in W units. W is taken at emission: particles live in image space and do not follow the head afterwards. Every particle length — speed, gravity, sizeScale — uses W taken at emission; 1.6's per-frame re-evaluation applies to non-particle layers only. (Behaviour decision (c) after the first draft, see the header.) Rationale: identical positions on any frame rate.
p(t) = p0 + v0·t + ½·g·t²
v0 = speed × (cos θ, sin θ)
g = (0, gravity)
7.10 [P] Spread and randomness. θ = directionDeg − spreadDeg/2 + spreadDeg × r, r ∈ [0, 1). r comes from a mulberry32 stream per layer per instance, seeded with the 32-bit FNV-1a hash of the UTF-8 string "<lensId>:<layerId>", one draw per emitted particle in emission order (dropped particles draw nothing). Angle is the only random quantity in v1. Rationale: without a pinned PRNG, particle layers can never pass a golden test.
directionDeg − spreadDeg/2 + spreadDeg × r
r ∈ [0, 1)
r
"<lensId>:<layerId>"
7.11 [P] play animation (action 6, §11.2) implies show of its clip's layer and (re)starts the clip from 0, replacing any clip playing on that layer; it cancels that clip's pending autoplay start. It names a clip (animation), not a layer.
play animation
animation
8.1 [S] §3.2 — A face lens has no durationMs and runs until stopped (a screen effect declares one, effect-rendering-v1.md E7.3).
durationMs
8.2 [P] Clock. Lens time = the input frame's presentation timestamp minus that of the first processed frame (never wall clock). Golden tests supply timestamps directly.
8.3 — Moved: startMs is a screen-effect field (effect-rendering-v1.md E7.2).
8.4 — Moved: the durationMs cut and effect.ended (effect-rendering-v1.md E7.3).
effect.ended
8.5 — Moved: a host stopping an effect early (effect-rendering-v1.md E7.4).
8.6 [P] A face lens's lifecycle ends when the host detaches it; there is no end event. Its triggers stop, and state is discarded (re-attaching starts fresh and fires lens.started again).
8.7 [S] §4.4 — On sustained overload the engine drops the face lens (raw frames pass through) and reports it.
8.8 — Moved: moving effect events between devices (effect-rendering-v1.md E7.5).
Screen motion is a screen-effect layer: effect-rendering-v1.md §E8 (shake, flash, pulse, and how they combine). Items 9.1–9.4 are not reused.
10.1 [P] Output size: a face lens outputs exactly the input frame's size and pixel format; it never crops or letterboxes.
10.2 [P] Asset colour/format: every asset is an 8-bit sRGB PNG (RGBA or RGB); 16-bit or palette PNGs are expanded to 8-bit RGBA at decode. Texture dimensions ≤ 1024 are already enforced at upload (manifest-v1.md notes).
10.3 [P] Sticker aspect: width is scale × W; height follows the asset's (or frame's) own aspect ratio — never the face's.
10.4 [P] Golden-test inputs. Add (outside the manifest) fixtures/render/: each case = a manifest + a sample frame + an explicit face-data file (the landmark points this document uses: eye centres, nose tip, menton, inner-lip centres, mouth corners, brow centres, eyelid points, eye corners) + timestamps (and event injections) → expected PNG. Plus fixtures/signals/: face data → expected signal values (6.1). Face data is injected, so no tracker runs in a golden test.
fixtures/render/
fixtures/signals/
10.5 [S] §5.3 — Renderers agree "within a tolerance". [P] Proposed tolerance: per channel |Δ| ≤ 2/255 on ≥ 99.5 % of pixels and ≤ 8/255 on all, after compositing over an opaque test background. (Counted under its leading [S]; the tolerance value itself is a proposal.)
|Δ| ≤ 2/255
≤ 8/255
10.6 [P] Initial state. At start every layer takes its manifest visible; sprites and emitters are idle except as 7.6 and 7.7 start them; no clip plays until its autoplay start or an action (§11.7).
10.7 [P] Particle cap is per layer (maxParticles) per instance; the cross-layer 300 total is a validation rule, not a runtime pool.
10.8 — Withdrawn: a lens has no screen layers, so face triggers and screen layers cannot mix.
10.9 [P] Forward path for fields. Because parsing is strict, a field added after the tag must come with a field-level engine level (a ENGINE_LEVEL_BY_FIELD table feeding computeMinEngineVersion), so an older SDK reports "engine too old" instead of "invalid manifest". No manifest change — a rule for how the editor computes minEngineVersion. format-v1.1.0 is the first use: ENGINE_LEVEL_BY_FIELD (clip lane, drive, a key's curve, any presence), ENGINE_LEVEL_BY_ANIMATION_PROPERTY (8, 9) and ENGINE_LEVEL_BY_EASING (8), all 2.
ENGINE_LEVEL_BY_FIELD
computeMinEngineVersion
lane
drive
curve
ENGINE_LEVEL_BY_ANIMATION_PROPERTY
ENGINE_LEVEL_BY_EASING
10.10 [P] Host face data (§4.2) must be supplied in the same un-mirrored image space as the frame (1.2); otherwise left/right anchors swap.
10.11 [P] Observation, no change proposed: there is no mouth anchor and head.tilt is unsigned, so "tilt left" vs "tilt right" and "from the mouth" effects are not expressible in v1. Adding an anchor value or event name later is non-breaking (a new engine level). The full-face anchor (10, 2.2a) was added before anything shipped, so it is engine level 1.
10.12 [P] Rendering is per frame and stateless apart from trigger arm state, sprite clocks, particle pools with their emission state, PRNG streams, and each layer's playing clip with its start time and the pending autoplay clip starts (§11.7) — the full list of per-instance state an SDK keeps.
A face lens's optional animations (manifest-v1 "Animations") each animate one layer over their own time. The value, easing and clip-clock rules are the screen effect's, pinned once.
11.1 [P] Value, easing, clip clock. Exactly effect-rendering-v1.md E10.1 (the value at a moment), E10.2 (the seven easings) and E10.3 (starts, visibility, looping, end, one clip per layer), with lens time (8.2) in place of effect time.
11.2 [P] Starts. An autoplay clip starts when lens time reaches its startMs (absent = 0), its clock at startMs — a scheduled start (6.9 step 1a). A play animation action (7.11) starts or restarts its clip on the frame of the event that fired it (lens.started on the first frame, a face-signal crossing, a host event), its clock at 0 at t, and cancels that clip's pending autoplay start. Starting a clip on a layer replaces the one playing there; properties the new clip does not animate return to rest at once.
11.3 [P] Frame order (6.9). Step 1a starts the scheduled autoplay clips; step 1b ends non-looping clips with the sprite clocks; play animation runs in steps 2–4 like every action (later actions win); step 6 draws every layer at its values at t, so a clip started on this frame shows its clip-time-0 values on this frame.
11.4 [P] What the values change.
11.5 [P] No face. Clip clocks run on lens time whether or not a face is tracked. Face-anchored layers are not drawn without a face (2.5) and reappear mid-clip when it returns.
11.6 [P] Visibility. hide does not stop a clip and show does not restart one — visibility and playback are independent, as for sprites (7.2).
11.7 [P] State. Each layer's playing clip (id, start time) and the pending autoplay starts, per instance (10.12). Empty at attach — no clip plays until its autoplay start or an action — and discarded on detach (8.6).
11.8 [P] Custom curve (engine 2). Easing 8 eases the segment by the key's curve (x1, y1, x2, y2), a CSS cubic-bézier from (0, 0) to (1, 1): x(s) = 3(1−s)²s·x1 + 3(1−s)s²·x2 + s³, y(s) = 3(1−s)²s·y1 + 3(1−s)s²·y2 + s³. For the segment fraction u: u ≤ 0 → 0; u ≥ 1 → 1; otherwise solve x(s) = u by exactly 40 bisection halvings — lo = 0, hi = 1; 40 times mid = (lo + hi) / 2, if x(mid) < u then lo = mid else hi = mid — and the eased fraction is y((lo + hi) / 2), in IEEE-754 double precision, each polynomial evaluated as written left to right (3·(1−s)·(1−s)·s·p1 + 3·(1−s)·s·s·p2 + s·s·s; other groupings may differ by a few ulps, inside the 10.5 tolerance). (x1, x2 ∈ [0, 1] make x non-decreasing, so the bisection is well defined.) Every other easing is E10.2's.
(x1, y1, x2, y2)
x(s) = 3(1−s)²s·x1 + 3(1−s)s²·x2 + s³
y(s) = 3(1−s)²s·y1 + 3(1−s)s²·y2 + s³
u ≤ 0
u ≥ 1
x(s) = u
lo = 0
hi = 1
mid = (lo + hi) / 2
if x(mid) < u then lo = mid else hi = mid
y((lo + hi) / 2)
3·(1−s)·(1−s)·s·p1 + 3·(1−s)·s·s·p2 + s·s·s
x
11.9 [P] Anchor track (engine 2, property 8). Keys hold anchor ids. At clip time c the anchor point is: before the first key or from the last key on, that key's anchor point; between keys a and b, P(a) + (P(b) − P(a)) × e, where P(n) is anchor n's point on this frame (2.1, 2.2) and e is key a's easing of the segment fraction (so Hold stays on a until b's time; back and bounce may overshoot the segment). This point replaces A in 1.8 (stickers, sprites on a face) and 2.6 (face particles); a particle takes the anchor point of its emission instant t_k (11.4), with this frame's landmarks.
c
a
b
P(a) + (P(b) − P(a)) × e
P(n)
n
e
11.10 [P] Roll follow (engine 2, property 9). A placed layer's roll follow f is its track value, else its resting value followRoll ? 1 : 0; it is clamped to [0, 1] when drawn. With R(θ) the rotation by θ (positive clockwise on screen, 1.9): P = A + W · R(f·roll) · (offset.x, offset.y) and the image turns by f·roll + rotation. At f = 1 and f = 0 a renderer uses 1.8's two formulas as written (face-frame vectors u, v; image axes), so engine-1 placements stay exact.
f
followRoll ? 1 : 0
R(θ)
θ
P = A + W · R(f·roll) · (offset.x, offset.y)
f·roll + rotation
f = 1
f = 0
11.11 [P] Lanes (engine 2). A clip's lane (1–4, absent = 1) splits a layer's playback: 11.2's "replaces the one playing there", the autoplay rule and 11.7's state are per layer and lane. Clips on other lanes keep playing. A property's drawn value is that of the highest lane whose playing clip has a track for it; if no playing clip has one, it rests. A non-looping clip that ended with end behaviour 2 is not playing (its lane falls through to lower lanes); one that ended with 1 holds its last values and keeps its lane.
11.12 [P] Signal-driven clips (engine 2). A clip with drive: { signal } starts like any clip (autoplay at startMs, or action 6), and from then on is always playing: its clip time on a frame is clamp01(s) × durationMs, where s is that frame's value of the signal (6.1, after the preview's overrides), or 0 while no face is tracked. loop and endBehavior have no effect. Particle catch-up (11.4) evaluates a driven clip with this frame's s at every t_k (the only signal value the frame has).
drive: { signal }
clamp01(s) × durationMs
endBehavior
11.13 [P] Combine (engine 3, format-v1.2.0). A clip's combine (absent = 1) sets how each of its tracks meets the value below it, the lanes taken in ascending order (11.11): 1 replace — the track's value is the property's value so far (the 11.11 rule, the highest lane wins); 2 add — the value so far plus the track's value; 3 multiply — the value so far times the track's value. "The value so far" is that of the lower lanes' playing clips with a track for the property, or the property's resting value when none has one: the layer's own field (offset, scale, rotation, opacity, intensity; roll follow followRoll ? 1 : 0; an animated sprite's opacity 1). The result then goes through the same clamps as any animated value (opacity and intensity to [0, 1], scale ≥ 0, roll follow to [0, 1], 11.4, 11.10). The anchor (8) holds anchor ids and always replaces. Key values stay within each property's key range (manifest-v1 "Animations"): an add clip offsets by them, a multiply clip scales by them.
format-v1.2.0
combine
Golden scenarios (packages/render/fixtures/scenarios/lens/, hand-checked): animation-sticker.json (a sticker keyed on a still face: offset, scale, rotation, opacity, back easing; followRoll on a tilted face), animation-mouth-open.json (a mouth.open crossing starts a clip), animation-particles.json (spawn offsets sampled at t_k), animation-colour-look.json (an intensity fade). Engine 2: animation-anchor.json (11.9), animation-roll-follow.json (11.10), animation-curve.json (11.8), animation-lanes.json (11.11), animation-driven.json (11.12). Engine 3: animation-combine.json (11.13: the lanes scenario with its lane-2 clip adding).
packages/render/fixtures/scenarios/lens/
animation-sticker.json
animation-mouth-open.json
animation-particles.json
animation-colour-look.json
animation-anchor.json
animation-roll-follow.json
animation-curve.json
animation-lanes.json
animation-driven.json
animation-combine.json
Engine 5 (format-v1.5.0) adds model layers (type 6) and model copies (type 7) to the face lens (manifest-v1 "3D"): the head pose and the occluder (12.1–12.6), placing a model on the head, the pass, copies on the frame, no face and the goldens (12.7–12.11). Shading, lighting presets, tone mapping and GLB clips are the screen effect's (effect-rendering-v1.md E12.5, E12.6, E12.8). [P] marks a value measured in the SDK labs before the format-v1.5.0 tag; until then it is provisional.
format-v1.5.0
12.1 [P] Camera and units. Rendering is in the un-mirrored frame (1.2). A pinhole camera sits at the origin looking down −z; camera space is +x image right, +y image up, +z towards the viewer. Its focal length f (pixels) is the host's, when the host gives its intrinsics; otherwise f = 0.75 × the frame's long side [P] (a 67° field of view across the long side, as laptop webcams and phone front cameras have). The principal point is the frame centre. A camera-space point p projects to (width/2 + f·p.x/(−p.z), height/2 − f·p.y/(−p.z)). On the face, lengths are face widths (1.6) and angles are degrees, positive by the right-hand rule in camera space.
f = 0.75 ×
p
(width/2 + f·p.x/(−p.z), height/2 − f·p.y/(−p.z))
12.2 [P] Head pose. From the five landmarks every tracker reports — the eye centres EL, ER, the nose tip N, the mouth centre Q (the corners' midpoint) and the chin C (menton) — with the face frame of 1.5–1.6 (E = 1.5's M, the eye midpoint; u, v; W):
N
Q
C
E
atan2(r·c − a, b − r·d)
r = ((N − E)·v) / ((Q − E)·v)
(Q − E)·v ≤ 0
atan2(((N − B)·u) / W, max(h·cos(pitch) + g·sin(pitch), 0.05))
B = (E + C) / 2
d
g
h
D = f·cos(yaw) / W
The five landmarks are the points of MediaPipe's face model that 12.4's pose landmarks were measured on. A renderer whose tracker places them elsewhere (another nose point, a jaw contour that misses the chin) corrects them for the pose only, so that a face looking into the camera reads as facing it (yaw and pitch 0 when the face is centred); 2D anchors and signals keep the tracker's points.
These are exact for a scaled-orthographic view of the canonical head, so the landmarks are first made one. Starting from the angles of the raw landmarks, repeat 8 times: with the current rotation R and depth D, scale each landmark's offset from the principal point by (D − z_i) / D, where z_i is the z of R·(P_i − P_E) (P_i its canonical point, P_E the canonical eye midpoint), and solve the angles again from the raw landmarks so scaled. The rotation is R = Rz(−roll) · Ry(yaw) · Rx(pitch) (pitch applied first; yaw positive turns the face towards the subject's left, which is the image's right; pitch positive looks down). The eye midpoint in camera space is the last scaled E back-projected to depth D (((E.x − width/2)·D/f, −(E.y − height/2)·D/f, −D)), and the head origin is that point minus R·P_E. The head matrix is translate(origin) · R. There is no pose while W is 0 (no face). Example (fixtures/pose/combined.json): a head made at yaw −15°, pitch −10°, roll 12°, origin (0.6, −0.4, −4.5) reads yaw −14.9993°, pitch −10.0028°, roll 12.0000°, origin (0.5999, −0.4000, −4.4996).
R
D
(D − z_i) / D
z_i
R·(P_i − P_E)
P_i
P_E
R = Rz(−roll) · Ry(yaw) · Rx(pitch)
((E.x − width/2)·D/f, −(E.y − height/2)·D/f, −D)
R·P_E
translate(origin) · R
fixtures/pose/combined.json
12.2a [P] Pose from the face mesh. When the host's tracker gives the whole face mesh (FaceData.mesh: at least 468 points, MediaPipe's face-mesh order, flat x, y, z; x, y in image pixels, z in pixels with smaller = nearer the camera), the pose is fitted to it instead of 12.2's five landmarks, and the face's own proportions are measured:
FaceData.mesh
CANONICAL_FACE_MESH_3D
y
MESH_FIT_ITERATIONS
(D − dz)/D
D = f/s
dz
dz·s
(q̄ₓ/s, q̄ᵧ/s, −D)
R·(p̄ ⊙ shape)
translate(origin) · R · scale(shape)
A mesh that cannot be fitted falls back to 12.2. Checked by packages/render/test/fit.test.ts: angles within 1° and the origin within 2% for faces 0.9–1.1 tall for their width, yaw ±40°, pitch ±25°.
packages/render/test/fit.test.ts
12.3 [P] Smoothing. The pose is smoothed by a One-Euro filter (Casiez et al. 2012) per value — yaw, pitch, roll in degrees and the origin's x, y, z in face widths — with min cutoff 1.0 Hz, derivative cutoff 1.0 Hz and β per kind of value [P]: 0.05 for the angles, 0.7 for the origin's x and y, 0.2 for its z (a head crossing the frame moves ~1–2 face widths a second but turns ~100° a second, so one β left the position at its 1 Hz floor and models trailed the face); α(fc, dt) = 1 / (1 + 1/(2π·fc·dt)), dt in seconds between frames. The first pose after a reset passes through; a frame whose time does not advance returns the last output; a frame with no face resets the filter (and has no pose). Roll is unwrapped to the raw value nearest the filtered one before filtering, and wrapped back to (−180°, 180°] after. The shape (12.2a) is smoothed by a plain low-pass, α(0.3 Hz, dt) (it settles in about a second and never shimmers); a pose without a shape clears it. 2D anchors stay unsmoothed (2.3): a few pixels of jitter that a sticker hides become visible wobble on a 3D model.
α(fc, dt) = 1 / (1 + 1/(2π·fc·dt))
dt
α(0.3 Hz, dt)
12.4 [P] Canonical head. The head frame is x towards the subject's left, y up, z out of the face, origin the head's centre; 1 unit = 1 face width. The ten anchors (CANONICAL_ANCHORS_3D) and the three pose landmarks (CANONICAL_NOSE_TIP_3D, CANONICAL_MOUTH_3D, CANONICAL_MENTON_3D):
CANONICAL_ANCHORS_3D
CANONICAL_NOSE_TIP_3D
CANONICAL_MOUTH_3D
CANONICAL_MENTON_3D
Pose landmarks [P] — where the tracked nose tip, mouth centre and chin really sit, measured from MediaPipe's metric canonical face model (vertices 1, 61/291 and 152), scaled so 2.2 × the eye-centre distance is 1 and placed with the eyes at anchors 2 and 3. They feed 12.2 only; anchors 4 and 7 keep their 2D sticker positions.
Face mesh [P] (12.2a) — CANONICAL_FACE_MESH_3D: all 468 vertices of the same MediaPipe canonical model, in the same frame and scale (generated by packages/format/scripts/extract_face_mesh.py); vertex i is tracked landmark i. Its vertices 1, 152 and the mouth corners are the pose landmarks above.
packages/format/scripts/extract_face_mesh.py
i
Each anchor's x and y is its 2D position seen from the front: 2.2's offsets, with y up and measured from the full-face point (so the eyes are ±1/4.4 apart from the centre, since W = 2.2 × the eye distance). A 3D object at an anchor therefore sits where a 2D sticker at that anchor does. The depths are the 3D board spec's.
12.5 The head occluder. fixtures/models/head-occluder.v1.glb: an ellipsoid with radii (0.48, 0.875, 0.66) face widths (HEAD_OCCLUDER_RADII) centred on (0, 0.125, 0) in the head frame (HEAD_OCCLUDER_CENTRE), so it reaches from the chin (y −0.75) to the top of the skull (y 1.0) and hides the back of a crown worn on the head, 16 rings × 24 segments (720 triangles), every face anchor on or just outside it [P]. When scene3d.occluder is true, or scene3d is absent, it is posed by the head matrix and drawn depth-only before every model of the lens, so what is behind the head is hidden by it. It is never drawn in colour, and its triangles do not count towards scene.triangles_over_cap.
fixtures/models/head-occluder.v1.glb
HEAD_OCCLUDER_RADII
HEAD_OCCLUDER_CENTRE
scene3d.occluder
scene3d
scene.triangles_over_cap
With the face mesh (12.2a), the occluder is the tracked face itself, closed at the back by the ellipsoid. Its front is the 468 canonical vertices with CANONICAL_FACE_MESH_TRIANGLES over them (MediaPipe's 898, counter-clockwise from the front), drawn both sides: vertex i is placed by the head matrix for its depth z, then moved along its pixel's ray to where the tracker saw it, ((u − W/2)·(−z)/f, −(v − H/2)·(−z)/f, z), so it has the face's own outline and expression. Its back is the ellipsoid's points at or behind head-frame z HEAD_OCCLUDER_BACK_Z (0.45 [P]): a clip plane through that point, normal to the head's z axis, keeps the back. The face mesh's rim reaches behind that plane, so the two overlap. Both are depth-only. Without the mesh, the whole ellipsoid, as above.
CANONICAL_FACE_MESH_TRIANGLES
z
((u − W/2)·(−z)/f, −(v − H/2)·(−z)/f, z)
HEAD_OCCLUDER_BACK_Z
12.6 Fixtures. packages/format/fixtures/pose/ (README there): landmark sequences with each frame's expected raw and filtered pose; a renderer matches each value within 1e-4. The occluder model is in fixtures/models/. The face-lens state golden is packages/render/fixtures/scenarios/lens/model-3d.json; the image goldens are 12.11's.
packages/format/fixtures/pose/
fixtures/models/
packages/render/fixtures/scenarios/lens/model-3d.json
12.7 Placing a model. A model layer's values are its resting values (transform3d and opacity) merged with its clips' (§11). Its anchor point is the canonical point (12.4) of transform3d.anchor, or, with an anchor track (11.9), the point gliding between the two anchors' canonical points along the track's easing. With followHead true its matrix is head · translate(anchor + offset) · Rz(rotation) · Ry(rotation y) · Rx(rotation x) · scale(scale); with followHead false it is translate(head · anchor + offset) · Rz · Ry · Rx · scale — the anchor follows the head, the model keeps the camera's orientation, and the offset is in camera axes (as 2D followRoll: false, 1.8). The GLB's node transforms come after. Opacity is clamped to [0, 1]; the GLB's own clip is E12.8's.
transform3d
transform3d.anchor
followHead
head · translate(anchor + offset) · Rz(rotation) · Ry(rotation y) · Rx(rotation x) · scale(scale)
translate(head · anchor + offset) · Rz · Ry · Rx · scale
12.8 The pass. All model and copies layers of a lens are drawn in one 3D pass with one depth buffer, composited premultiplied source-over at the position of the first model or copies layer in layers (E12.4's rule; 2D layers keep their order around it). The camera is 12.1's; the lights are E12.6's, their directions in camera space; shading and tone mapping are E12.5's. When a head is tracked and scene3d.occluder is true (or scene3d is absent), the occluder (12.5) posed by the head matrix is drawn first, writing depth only; then opaque and MASK materials front to back, then BLEND materials back to front by their centres (E12.4). A lens has no screen motion. The draw list's pass3d carries camera: { focalPx } and, with the occluder, occluder: { asset: "head-occluder.v1.glb", matrix }, plus mesh (the tracked face's 468 vertices in camera space, flat, 12.5) when the face has a mesh; SDKs bundle that GLB (HEAD_OCCLUDER_ASSET), manifests never list it.
layers
pass3d
camera: { focalPx }
occluder: { asset: "head-occluder.v1.glb", matrix }
mesh
HEAD_OCCLUDER_ASSET
12.9 Copies on the frame. A copies layer's physics is E12.7's in frame fractions — x of the frame's width, y of its height, radii scale × S / 2 over the width and the height with S the frame's short side in pixels — with gravity straight down (no tilt). A copy at (x, y) is drawn at camera-space ((x·W − W/2)/f, −(y·H − H/2)/f, −1), on the plane 1 face width in front of the camera, spun about its axis, scaled scale × S / f, so a model unit spans scale × S pixels. It is in front of every head, so the occluder never hides it.
scale × S / 2
((x·W − W/2)/f, −(y·H − H/2)/f, −1)
scale × S / f
scale × S
12.10 No face. While no face is tracked, model layers are not drawn (their clip clocks keep running), the pass has no occluder, and copies keep falling and are drawn. The pose filter resets (12.3).
12.11 Goldens. The state golden packages/render/fixtures/scenarios/lens/model-3d.json (tolerance 0.002, as every scenario): a moving head, followHead both ways, a copies burst, a clip start and a lost face. The image goldens packages/format/fixtures/render3d/face-*.json with their PNGs are each one face lens's pass3d — overlay is the frame, pass.camera its camera, pass.occluder the occluder, named in models — rendered by the editor's drawer and compared with E12.10's metric (SSIM ≥ 0.98, at most 1 % of pixels off by more than 16).
packages/format/fixtures/render3d/face-*.json
overlay
pass.camera
pass.occluder
models
Changed from the 3D board spec (plan 1b-1): engine 5 instead of 4 (engine 4 shipped as screen-effect 3D); the anchors' x and y recomputed from 2.2 (the spec's table used another face width); exact orthographic formulas with the yaw read from the nose against the chin (the spec's nose-against-the-eyes cue vanishes when the head looks down about 25°); the perspective correction (without it a 20° pitch read up to 13° wrong at phone distance); the head placed by the eye midpoint, with cos(yaw) undoing the foreshortened eye distance (placing it by the full-face point drew the face about 19% too big); and an ellipsoid occluder.
cos(yaw)
A face-paint layer (type 8, manifest-v1.md "Face paint") draws one PNG, painted on the face map, on the tracked face. The renderer emits one draw command per frame, mesh, while a face is tracked and the asset has a size:
{ op: 'mesh', layerId, asset, points, triangles, opacity, blend }
13.1 Points. The face's 468 points in frame pixels (x right, y down), flat x, y. With the tracked face mesh (12.2a), point i is the mesh's point i (its x, y). Without one, the canonical mesh (CANONICAL_FACE_MESH_3D) is placed by this frame's head matrix (12.2, 12.3) and projected by the 12.1 camera: with c = head · vertex, u = W/2 + f·c.x/(−c.z), v = H/2 − f·c.y/(−c.z). Without a face, nothing is drawn.
x, y
u = W/2 + f·c.x/(−c.z)
v = H/2 − f·c.y/(−c.z)
13.2 The face map. Point i samples the texture at CANONICAL_FACE_MESH_UV[2i], [2i + 1] (MediaPipe's canonical UVs): u grows towards the subject's left and v is 0 at the texture's top row, so the texture reads like a face looking at you. The editor's Download the face template draws the mesh on this map, 1024².
CANONICAL_FACE_MESH_UV[2i], [2i + 1]
13.3 Holes. The canonical mesh covers the eyes and the mouth. With holes.eyes, the triangles numbered in FACE_MESH_EYE_HOLES are left out (14 per eye, inside MediaPipe's closed eye contours); with holes.mouth, those in FACE_MESH_MOUTH_HOLES (18, inside the inner lips). Triangle k is CANONICAL_FACE_MESH_TRIANGLES[3k..3k + 2].
holes.eyes
FACE_MESH_EYE_HOLES
holes.mouth
FACE_MESH_MOUTH_HOLES
CANONICAL_FACE_MESH_TRIANGLES[3k..3k + 2]
13.4 Front faces only. A triangle (a, b, c) is drawn only when it faces the camera: in frame pixels, (b.x − a.x)·(c.y − a.y) − (b.y − a.y)·(c.x − a.x) < 0 (the canonical triangles are counter-clockwise from the front in the y-up head frame). So the far side of a turned head, hidden behind the nose and cheek, is not painted over the near side. triangles lists the kept triangles' vertex indices, 3 each, in canonical order.
(b.x − a.x)·(c.y − a.y) − (b.y − a.y)·(c.x − a.x) < 0
triangles
13.5 Blending. The texel S (premultiplied, sampled bilinearly) × opacity is blended over the frame so far (the camera image and the layers drawn before it), D, per channel: normal out = S + D·(1 − Sa); multiply out = S·D + D·(1 − Sa); screen out = S + D·(1 − S). opacity is the layer's, or its animated value (property 5), clamped to [0, 1].
out = S + D·(1 − Sa)
out = S·D + D·(1 − Sa)
out = S + D·(1 − S)
13.6 Order. The layer is drawn at its place among the 2D layers (§5). It comes before every 3D layer (the rule faceMesh.after_3d), so models are drawn over the paint; the head occluder (12.5) never hides paint. Show, hide and the opacity clips work as on any layer.
faceMesh.after_3d
13.7 Golden. packages/render/fixtures/scenarios/lens/face-paint.json: a frontal face with a tracked mesh, a turned face without one (13.1's projection), a smile that hides the paint, and a lost face. Generated by packages/render/scripts/make-face-paint-scenario.ts (the tracked mesh is written there, not by the runtime); tolerance 0.002, as every scenario.
packages/render/fixtures/scenarios/lens/face-paint.json
packages/render/scripts/make-face-paint-scenario.ts
A face lens's 3D objects take the room's light, read from how the face is lit in the camera frame, unless the lens sets scene3d.roomLight 2 (manifest-v1 "Room light"). Engines before 7 draw the preset only. The reference is packages/render/src/runtime/lightEstimate.ts; every number below is a constant in packages/format/src/constants.ts.
scene3d.roomLight
packages/render/src/runtime/lightEstimate.ts
packages/format/src/constants.ts
14.1 Sampling (the host). While a face is tracked, at least every 100 ms, the host reads the camera frame (un-mirrored) at the 29 landmarks of LIGHT_SAMPLE_LANDMARKS, at 13.1's points (lightSamplePoints): the mean of the 3 × 3 pixels around each point, in the frame scaled so its long side is 256 px. It passes them, in that order, as faceColors (sRGB 0–1, r g b per point). A step without faceColors changes nothing: the last estimate holds.
LIGHT_SAMPLE_LANDMARKS
lightSamplePoints
faceColors
14.2 Fit. Each sample's normal is the area-weighted sum of the canonical triangles around its landmark, from (b − a) × (c − a) (canonicalLightNormals, head frame, outward), rotated by the head matrix into camera space. Samples with camera-space normal z < LIGHT_MIN_FACING (0.2) are dropped. Each colour is linearised (sRGB decode) and its luminance Y = 0.2126 r + 0.7152 g + 0.0722 b is fitted by least squares to Y = a + b·n (spherical harmonics L1: one ambient term a, one vector b towards the light). Fewer than LIGHT_MIN_SAMPLES (12) kept samples, or a singular system, gives no estimate for that step.
canonicalLightNormals
LIGHT_MIN_FACING
LIGHT_MIN_SAMPLES
14.3 Colour. The kept samples' mean linear RGB, divided by its own luminance and by LIGHT_SKIN_CHROMA (1.3, 0.93, 0.78) per channel, is the light's colour against a reference skin. It is halved toward white (c = 1 + (c − 1) / 2), clamped to 0.6–1.4 per channel, divided by its largest channel and encoded to sRGB hex. The key and the ambient share it.
LIGHT_SKIN_CHROMA
14.4 Strength and direction. ambient = 0.6 · a / LIGHT_REFERENCE_AMBIENT (0.217), clamped 0.05–1.5; key = 3.0 · |b| / LIGHT_REFERENCE_KEY (0.1684), clamped 0–4.5. The references are the fit of a reference-skin face under the Studio preset's light, so that face maps to Studio's ambient 0.6 and key 3.0. The key direction is b normalised; its camera-space z is raised to at least LIGHT_MIN_KEY_Z (0.2), x and y rescaled to keep unit length: every sample faces the camera, so the fit pins the toward-camera part poorly and side lights would otherwise come out behind the face. When |b| < 1e-4 the direction is Studio's key (0.5, 0.8, 0.6) normalised.
LIGHT_REFERENCE_AMBIENT
LIGHT_REFERENCE_KEY
LIGHT_MIN_KEY_Z
14.5 Smoothing. a, b and the colour (before 14.3's halving) are smoothed exponentially: on each new fit, value += (new − value) · (1 − e^(−Δt / LIGHT_SMOOTHING_MS)), Δt the time since the previous fit, 500 ms. The first fit is taken as is. Before it, the pass has no light.
LIGHT_SMOOTHING_MS
light
14.6 Drawing. With pass3d.light: the key light is light.key (direction, colour, intensity); the hemisphere ambient has sky light.ambient.color, the preset's ground and intensity light.ambient.intensity; the preset's fill keeps its direction and colour with intensity × light.ambient.intensity / the preset's ambient. Exposure and tone mapping are unchanged (E12.6).
pass3d.light
light.key
light.ambient.color
light.ambient.intensity
14.7 Worked example. fixtures/light/warm-lamp.json: a frontal face of reference skin under a warm lamp (linear colour 1.3, 1.0, 0.65) towards (0.7, 0.6, 0.4), ambient 0.5, key 0.6. The estimate: key direction (0.695, 0.691, 0.2), colour #fff0dd, key 2.883, ambient 0.769.
fixtures/light/warm-lamp.json
#fff0dd
14.8 Pinned cases. packages/format/fixtures/light/: warm-lamp, cold-daylight, side-light (head turned 20°), dim-room. Each gives headPose, faceColors and the reference estimate; an SDK matches it within the file's tolerance (direction components ±0.02, intensities ±0.05, colour channels ±2 of 255). Generated by packages/render/scripts/make-light-fixtures.ts.
packages/format/fixtures/light/
warm-lamp
cold-daylight
side-light
dim-room
headPose
tolerance
packages/render/scripts/make-light-fixtures.ts
Known limit. Cameras correct their own exposure and white balance, which partly hides a warm or dim room; the direction is the robust part of the estimate.