Renderer · interface

SurfaceRim

Light along the silhouette: the edge (1 - N·V)^falloff, leaning toward normals that face up, raised to a contrast, times a noise laid in screen space, a slow pulse and a mask, in a colour. Added to what the surface emits, and not gated on the night as emission is: it is a glow the surface wears, not light it gives off.

Explained in Hello world.

interface SurfaceRim
import type { SurfaceRim } from '@driftengine/core';

In depth

Or, with mode: 'blend', a colour the surface is pulled toward, lit like the rest of it: the base colour mixed toward the rim's by the edge times alpha, before any light reads it, so the rim is bright where light falls and dark where none does. The colour is colour times intensity, each channel held at 1 as a base colour is, so a colour of 8 red is a red of 1 and not a glow; alpha is the weight, which may pass 1 to saturate the edge sooner.

Properties

NameTypeDescription
colourreadonlyVec3
intensityreadonlynumberHow bright, 0 for none, multiplied with alpha. Where the rim blends it scales colour instead, so 0 there is a rim of black, and alpha alone says how much: 0 for none.
alphareadonlyoptionalnumberThe rim's weight, 1 unless given.
modereadonlyoptional'add' | 'blend''add', the default, lays the rim on as glow; 'blend' pulls the base colour toward it, lit.
falloffreadonlyoptionalnumberThe edge's exponent: larger keeps the rim nearer the silhouette. 1.5 unless given.
upwardreadonlyoptionalnumberHow far the rim leans toward normals that face up: the weight is (N·up · ½ + ½)^upward, so 0 is no lean. 0.4 unless given.
contrastreadonlyoptionalnumberThe exponent the whole edge is raised to. 1 unless given.
noisereadonlyoptional{ readonly region: OverlayRegion; /** Screens a second, along x and y. */ readonly scroll?: readonly [number, number]; /** Repeats across the screen's height. 1 unless given. */ readonly tiling?: number; }A noise image laid in screen space and scrolled, the rim taken times it, clamped to 1.
pulsereadonlyoptional{ readonly rate: number; readonly low: number; readonly high: number; }A pulse ½ + ½ sin(rate · t), held between low and high, on Environment.surfaceTime.
maskreadonlyoptional{ readonly region: OverlayRegion; readonly weight: number; }A mask in the mesh's uv where the rim is erased: the rim times 1 - weight · mask.