# Post filters and glow


A post filter runs over the finished pixels of a [group](/docs/group/): everything the group drew is handed to a small shader, and what the shader returns is what lands on the stage. That is how you split colors, break a picture into dots, bend it through a lens or send a shockwave through it, things no amount of moving shapes around can do.

```odin
if fx.group({post = fx.rgb_split(8)}) {
	fx.caption("split", {960, 540}, 220, fx.theme.nt, {0.5, 0.5})
}
```

Each procedure on this page returns a `Post`, a value for the `post` field of `Xf`. A group takes one post; nest groups to chain two. Lengths and positions are in stage px, in the group's own coordinates.

Most filters return an empty `Post` when their main argument is close to zero, and a group with an empty post is drawn as if it had none. So `post = fx.rgb_split(12 * k)` can stay in the code and costs nothing on the frames where `k` is 0. `duotone`, `scanlines` and `stretch` have no such argument and always run.

## Splitting and breaking

```odin
rgb_split :: proc(px: f32, angle: f32 = 0) -> Post
glitch    :: proc(amount: f32, seed: f32 = 0) -> Post
```

`rgb_split` is chromatic aberration: red is read `px` to one side and blue `px` to the other, along `angle` in degrees (0 is horizontal, 90 vertical). Green stays where it is. A pixel or two reads as a lens, ten or more as a hit.

```odin
post_rgb_split :: proc(s: fx.Shot) {
	fx.backdrop(.Night)
	px := knob("px", 12, 0, 40)
	angle := 90 * s.lt // one turn per loop
	if fx.group({post = fx.rgb_split(px, angle)}) {
		fx.caption("Aberration", {960, 440}, 250, fx.theme.nt, {0.5, 0.5})
		fx.hline(330, 640, 1260, fx.theme.nt, 6)
		fx.circle({960, 780}, 60, fx.theme.na)
	}
}
```

`glitch` cuts the picture into 6 to 23 horizontal bands, shoves some of them sideways and splits the colors of all of it, and rolls new dice 24 times a second. `amount` runs from 0 to 1: at 1 about 60% of the bands move, by as much as 6% of the stage width, and red and blue are each pulled up to 34 px to their side. It reads the frame's time itself, so there is nothing to animate; `seed` gives a second glitch on the same frame a different pattern.

```odin
post_glitch :: proc(s: fx.Shot) {
	amount := knob("amount", 0.5, 0, 1)
	if fx.group({post = fx.glitch(amount)}) {
		fx.backdrop(.Night)
		fx.rect({0, 300, 1920, 8}, fx.theme.na)
		fx.caption("NO SIGNAL", {960, 500}, 240, fx.theme.nt, {0.5, 0.5})
		fx.label("CH 03  ·  00:14:27", {960, 700}, fx.mono(56), fx.theme.nm, {0.5, 0.5})
		fx.rect({0, 790, 1920, 8}, fx.theme.na)
	}
}
```

## Blur and pixels

```odin
zoom_blur :: proc(center: Vec2, amount: f32) -> Post
pixelate  :: proc(px: f32) -> Post
```

`zoom_blur` smears every pixel along the line toward `center`: the rush of a fast zoom. `amount` is the part of that line it smears over, 0 to 1, and 0.15 is already a lot. Pair it with a scale that settles at the same time.

```odin
post_zoom_blur :: proc(s: fx.Shot) {
	rush := 1 - fx.ep(s.lt, 0.2, 1.6, fx.ease_out5) // 1 at the start, settling to 0
	amount := knob("amount", 0.2, 0, 0.4) * rush
	c := fx.Vec2{960, 540}
	if fx.group({s = 1 + 0.5 * rush, origin = c, post = fx.zoom_blur(c, amount)}) {
		fx.backdrop(.Night)
		for i in 0 ..< 60 {
			p := fx.Vec2{fx.hash01(1, i) * 1920, fx.hash01(2, i) * 1080}
			fx.circle(p, 4 + 10 * fx.hash01(3, i), i % 5 == 0 ? fx.theme.na : fx.theme.ns)
		}
		fx.caption("Arrive", c, 280, fx.theme.nt, {0.5, 0.5})
	}
}
```

`pixelate` turns the group into squares `px` wide, each in the color at its middle. Below 1.5 it does nothing.

```odin
post_pixelate :: proc(s: fx.Shot) {
	px := knob("px", 28, 1, 96)
	if fx.group({post = fx.pixelate(px)}) {
		fx.backdrop(.Night)
		a := s.p * math.TAU
		c := fx.Vec2{960 + 520 * math.cos(a), 540 + 230 * math.sin(a)}
		fx.circle_paint(c, 190, fx.radial(c - {60, 60}, 260, fx.theme.nt, fx.theme.na, fx.theme.night))
		fx.caption("8-bit", {960, 540}, 300, fx.theme.nt, {0.5, 0.5})
	}
}
```

## Tone and print

```odin
duotone   :: proc(dark, light: Color) -> Post
scanlines :: proc(px: f32 = 4, amount: f32 = 0.25) -> Post
halftone  :: proc(cell: f32, angle: f32 = 45, amount: f32 = 1) -> Post
dither    :: proc(px: f32 = 2, dark: Color = 0xff000000, light: Color = 0xffffffff, levels: f32 = 2, amount: f32 = 1) -> Post
```

`duotone` replaces color by brightness: black becomes `dark`, white becomes `light`, everything else a mix of the two. Transparency is kept. It is the quickest way to make footage or a busy picture belong to a palette.

```odin
post_duotone :: proc(s: fx.Shot) {
	picture :: proc() {
		fx.rect_paint(fx.stage(), fx.linear({0, 0}, {0, 1080}, 0xff16254a, 0xff8a3b5e, 0xfff09a4a, 0xffffe2a0))
		fx.circle_paint({960, 700}, 230, fx.radial({960, 700}, 230, 0xfffffbe6, 0xffffd978))
		fx.circle({420, 1560}, 760, 0xff203a3a)
		fx.circle({1420, 1700}, 900, 0xff0f2226)
		fx.caption("Two inks", {960, 300}, 200, 0xfffff6e0, {0.5, 0.5})
	}
	picture()
	x := 960 - 760 * math.cos(s.p * math.TAU) // the border wipes across and back
	if fx.group({clip = fx.Rect{x, 0, 1920 - x, 1080}, post = fx.duotone(fx.theme.night, fx.theme.na)}) {
		picture()
	}
	fx.vline(x - 2, 0, 1080, fx.theme.nt, 4)
}
```

`scanlines` darkens the picture in horizontal lines `px` apart, by `amount` (0 to 1) at the darkest row. The default of 4 px suits a full-size render; the demo uses wider lines so they survive the small player.

```odin
post_scanlines :: proc(s: fx.Shot) {
	px := knob("px", 12, 2, 40)
	amount := knob("amount", 0.5, 0, 1)
	if fx.group({post = fx.scanlines(px, amount)}) {
		fx.rect(fx.stage(), 0xff0b1a12)
		fx.rrect({160, 150, 1600, 780}, 40, 0xff12301f)
		green: fx.Color = 0xff7dffb0
		fx.text(fx.typed("> load \"film\"", s.lt, 0.3, 1.4), 260, 250, fx.mono(96, 500), green)
		fx.text(fx.typed("3600 frames ready", s.lt, 1.7, 2.6), 260, 420, fx.mono(96, 500), green)
		if math.mod(s.lt, 0.5) < 0.25 do fx.rect({260, 620, 58, 104}, green)
	}
}
```

`halftone` is print: a grid of dots `cell` px apart, turned by `angle` degrees. Each dot is as big as the picture is bright under it and takes the picture's color there at full strength, on black. `amount` (0 to 1) blends the dots in from the untouched picture, which is how you fade into the effect.

```odin
post_halftone :: proc(s: fx.Shot) {
	cell := knob("cell", 26, 4, 80)
	angle := knob("angle", 45, 0, 90)
	if fx.group({post = fx.halftone(cell, angle)}) {
		fx.rect_paint(fx.stage(), fx.linear({0, 0}, {1920, 1080}, 0xff3a1410, fx.theme.na, 0xffffe2a0))
		c := fx.Vec2{560 + 800 * s.p, 560}
		fx.circle_paint(c, 300, fx.radial(c - {110, 120}, 520, 0xffffffff, 0xff4f8fd0, 0xff0a1020))
		fx.caption("PRINT", {1380, 800}, 300, 0xffffffff, {0.5, 0.5})
	}
}
```

`dither` is an ordered dither (an 8×8 Bayer pattern) in pixels `px` wide. The brightness is cut down to `levels` shades between `dark` and `light`; 2 is one bit, the look of an early Macintosh. `amount` blends it in like `halftone`'s.

```odin
post_dither :: proc(s: fx.Shot) {
	px := knob("px", 6, 1, 16)
	levels := knob("levels", 2, 2, 6)
	if fx.group({post = fx.dither(px, fx.theme.night, fx.theme.nt, levels)}) {
		fx.rect_paint(fx.stage(), fx.linear({0, 0}, {1920, 0}, 0xff000000, 0xffffffff))
		c := fx.Vec2{960 + 520 * math.sin(s.p * math.TAU), 470}
		fx.circle_paint(c, 300, fx.radial(c - {110, 120}, 520, 0xffffffff, 0xff777777, 0xff000000))
		fx.rect({0, 800, 1920, 280}, 0xff000000)
		fx.caption("1-bit", {960, 940}, 190, 0xffffffff, {0.5, 0.5})
	}
}
```

## Lenses and waves

```odin
lens      :: proc(distort: f32 = 0.06, chroma: f32 = 6, vignette: f32 = 0) -> Post
shockwave :: proc(center: Vec2, radius, width, strength: f32) -> Post
kaleido   :: proc(center: Vec2, n: f32 = 6, angle: f32 = 0, zoom: f32 = 1) -> Post
warp      :: proc(amount: f32, scale: f32 = 240, speed: f32 = 0.4, seed: f32 = 0) -> Post
stretch   :: proc(edge: f32, horizontal := true, forward := true) -> Post
```

`lens` is a whole camera lens in one filter. `distort` is barrel distortion: above 0 the middle bulges toward you while the corners stay put, below 0 it pinches. `chroma` pulls the colors apart toward the edges, by about that many px in the corners and not at all in the middle. `vignette` (0 to 1) darkens the edges. It is centered on the stage, so it belongs on a group that covers the stage, typically the film's `master` group (see [scenes](/docs/scenes/)). Keep `distort` small: the fable film runs at 0.016.

```odin
post_lens :: proc(s: fx.Shot) {
	distort := knob("distort", 0.08, -0.2, 0.2)
	chroma := knob("chroma", 12, 0, 40)
	vignette := knob("vignette", 0.6, 0, 1)
	if fx.group({post = fx.lens(distort, chroma, vignette)}) {
		fx.backdrop(.Night, offset = {60 * s.lt, 0}) // the grid drifts, so the bend shows
		fx.border({120, 90, 1680, 900}, fx.theme.ns, 4, 40)
		fx.caption("Through glass", {960, 480}, 210, fx.theme.nt, {0.5, 0.5})
		fx.label("fx.lens(distort, chroma, vignette)", {960, 680}, fx.mono(40), fx.theme.nm, {0.5, 0.5})
	}
}
```

`shockwave` is a ring-shaped ripple around `center`. `radius` is where the ring is, `width` how thick, `strength` how many px it pushes the picture outward at its crest (negative pulls inward). The crest splits colors a little and brightens. Animate `radius` outward and let `strength` fall to 0 on the way.

```odin
post_shockwave :: proc(s: fx.Shot) {
	strength := knob("strength", 70, -120, 120)
	width := knob("width", 130, 20, 400)
	c := fx.Vec2{960, 540}
	p := fx.prog(s.lt, 0.3, 2.7)
	// the ring runs outward and loses its force on the way
	if fx.group({post = fx.shockwave(c, 1300 * p, width, strength * (1 - p))}) {
		fx.backdrop(.Night)
		for i in 0 ..< 7 {
			fx.label("impact impact impact impact impact", {960, 150 + f32(i) * 130}, fx.sans(90, 600), i == 3 ? fx.theme.nt : fx.theme.ns, {0.5, 0.5})
		}
	}
}
```

`kaleido` folds the group into mirrored wedges around `center`. `n` is how many times the pattern repeats around the circle; `angle` (degrees) turns it, `zoom` magnifies it. What would be read from outside the stage is folded back in, so the wedges are always full. Anything drifting through the picture turns into a mandala.

```odin
post_kaleido :: proc(s: fx.Shot) {
	n := math.round(knob("n", 6, 1, 12))
	if fx.group({post = fx.kaleido({960, 540}, n, 45 * s.lt)}) {
		fx.rect(fx.stage(), fx.theme.night)
		// rows of pills drifting to the right: two columns per loop
		for i in 0 ..< 24 {
			col, row := f32(i % 6), f32(i / 6)
			x := math.mod(col * 400 + row * 130 + 100 * s.lt, 2400) - 240
			c := i % 2 == 0 ? fx.theme.na : (row == 1 ? fx.theme.ns : fx.theme.nt)
			fx.rrect({x, 100 + row * 270, 240, 70}, 35, c)
			fx.ring({x + 120, 135 + row * 270}, 100, fx.alpha(c, 0.5), 6)
		}
	}
}
```

`warp` pushes pixels around with flowing noise: heat haze at 5 px, liquid at 40, a melting picture beyond that. `amount` is the push in px, `scale` the size of the swirls in px, `speed` how fast they flow. Like `glitch` it reads the frame's time, and `seed` picks a different flow.

```odin
post_warp :: proc(s: fx.Shot) {
	amount := knob("amount", 50, 0, 200)
	scale := knob("scale", 240, 40, 800)
	if fx.group({post = fx.warp(amount, scale)}) {
		fx.backdrop(.Night)
		for i in 0 ..< 9 do fx.hline(260, 220 + f32(i) * 80, 1400, i == 4 ? fx.theme.na : fx.theme.nb, 6)
		fx.caption("Heat haze", {960, 540}, 250, fx.theme.nt, {0.5, 0.5})
	}
}
```

`stretch` repeats one column of pixels: everything right of `x = edge` becomes the column at the edge, smeared across. With `forward = false` it is everything left of it; with `horizontal = false` the edge is a `y` and rows are smeared down (or, not `forward`, up).

```odin
post_stretch :: proc(s: fx.Shot) {
	// the edge sweeps in from the right, holds, and goes back
	k := fx.win(s.lt, 0.4, 4.6, 1.4, 1.4)
	edge := fx.lerp(1920, 850, k)
	if fx.group({post = fx.stretch(edge)}) {
		fx.backdrop(.Night)
		fx.rect({0, 250, 1920, 12}, fx.theme.na)
		fx.caption("Stretched", {960, 500}, 280, fx.theme.nt, {0.5, 0.5})
		fx.label("everything right of the edge is one column of pixels", {960, 730}, fx.sans(48), fx.theme.nm, {0.5, 0.5})
		fx.rect({0, 840, 1920, 12}, fx.theme.ns)
	}
	fx.vline(edge, 0, 1080, fx.alpha(fx.theme.nt, 0.3), 2)
}
```

## Your own filter

```odin
Post :: struct {
	sksl:   cstring,
	u:      [16]f32, // uniforms in declaration order
	n:      int,
	radius: f32, // how far it samples away from a pixel, in px
}

post :: proc(sksl: cstring, radius: f32, uniforms: ..f32) -> Post
```

Every filter above is a few lines of SkSL (Skia's shading language, close to GLSL) handed to `post`, and yours can be too. The contract:

```glsl
uniform shader src;    // the group's pixels; must have this name
uniform float amp;     // your uniforms, floats only
uniform float2 center; // a float2 takes two of the numbers you pass, a float3 three

half4 main(float2 p) { // p: this pixel, in stage px
	return src.eval(p + float2(amp, 0)); // read the group anywhere; colors are premultiplied
}
```

- The numbers after `radius` fill the uniforms in the order they are declared. There is room for 16 floats; more are dropped, and uniforms you do not fill are 0.
- `radius` is the furthest the shader reads from its own pixel, in px. Skia uses it to keep enough of the picture around the area it is drawing; 0 is right for filters that only read `src.eval(p)`.
- Nothing is passed for you. If the filter moves, pass `s.t` as a uniform; if it needs the stage size, pass that.
- A shader that does not compile prints Skia's error and the group is drawn unfiltered.

`unpack(color)` turns a `Color` into an `RGBA` of four floats in 0..1, which is how colors get into uniforms. The built-in sources are public constants (`fx.RGB_SPLIT`, `fx.LENS`, …) and `fx/post.odin` is short: read it for more examples.

```odin
post_custom :: proc(s: fx.Shot) {
	// every row is read from a little to the left or right of where it is
	WAVE :: `
	uniform shader src;
	uniform float amp;
	uniform float len;
	uniform float t;
	half4 main(float2 p) {
		return src.eval(p + float2(amp * sin(p.y / len + t), 0));
	}`
	amp := knob("amp", 40, 0, 160)
	len := knob("len", 60, 10, 300)
	// radius = amp: the furthest the shader reads from its own pixel
	if fx.group({post = fx.post(WAVE, amp, amp, len, s.p * math.TAU)}) {
		fx.backdrop(.Night)
		fx.caption("Your own", {960, 420}, 260, fx.theme.nt, {0.5, 0.5})
		fx.rrect({460, 640, 1000, 120}, 60, fx.theme.na)
	}
}
```

## Glow

```odin
Glow :: struct {
	radius:        f32, // blur sigma in px
	amount:        f32, // 0 = off; 1 adds the blurred highlights at full strength
	threshold:     f32, // 0..1: only what is brighter glows
	streak:        f32, // horizontal sigma of the streak pass, 0 = none
	streak_amount: f32, // of amount, default 0.6
}

glow :: proc(radius: f32 = 24, amount: f32 = 0.8, threshold: f32 = 0.5, streak: f32 = 0) -> Glow
```

Glow is bloom, and it has its own field on `Xf`: `fx.group({glow = fx.glow()})`. What is brighter than `threshold` is cut out, blurred by `radius` and added back on top, `amount` strong. Each color channel is judged on its own, so a saturated red glows red. It works best on a group that paints its own background, because the glow needs something to land on.

```odin
post_glow :: proc(s: fx.Shot) {
	radius := knob("radius", 30, 0, 120)
	amount := knob("amount", 1, 0, 3)
	threshold := knob("threshold", 0.5, 0, 0.95)
	if fx.group({glow = fx.glow(radius, amount, threshold)}) {
		fx.backdrop(.Night) // inside: the glow has a background to land on
		fx.caption("Bloom", {960, 400}, 300, fx.theme.nt, {0.5, 0.5})
		// from dim to bright: only what is above the threshold glows
		for i in 0 ..< 8 {
			fx.rrect({300 + f32(i) * 170, 690, 130, 130}, 24, fx.mix(fx.theme.night, fx.theme.na, f32(i + 1) / 8))
		}
		x := 300 + 1320 * fx.ep(s.lt, 0.3, 3.4, fx.ease_in_out)
		fx.circle({x, 900}, 14, 0xffffffff)
	}
}
```

`streak` adds a second pass of the same highlights, blurred `streak` px wide and hardly at all in height: the horizontal flare of an anamorphic lens. Its strength is `streak_amount` of `amount`, 0.6 unless you say otherwise. `glow()` has no argument for that, so write the struct when you need it:

```odin
glow = {radius = 20, amount = 0.45, threshold = 0.58, streak = 110, streak_amount = 0.4}
```

> **Note:** A struct literal starts from zeros, not from `glow()`'s defaults: leave `threshold` out of it and everything glows, not only the highlights.

```odin
post_streak :: proc(s: fx.Shot) {
	streak := knob("streak", 140, 0, 400)
	if fx.group({glow = {radius = 16, amount = 0.9, threshold = 0.6, streak = streak, streak_amount = 0.8}}) {
		fx.rect(fx.stage(), fx.theme.night)
		for i in 0 ..< 14 {
			x := math.mod(fx.hash01(5, i) * 1920 + (40 + 80 * fx.hash01(6, i)) * s.lt * 1920 / 400, 1920)
			fx.circle({x, 140 + fx.hash01(7, i) * 800}, 5 + 9 * fx.hash01(8, i), i % 4 == 0 ? fx.theme.na : 0xffffffff)
		}
		fx.caption("Anamorphic", {960, 540}, 220, fx.theme.nt, {0.5, 0.5})
	}
}
```

## Order

Inside one group the steps always run in the same order: the group's `blur`, then its `post`, then its `glow`, then its grade (`gray`, `bright`, `contrast`, `sat`, `tint`, `invert`), and last its opacity and blend onto what is below.

So a post sees the picture before the grade of its own group. When the filter should work on the graded picture (a dither after a gray grade, a duotone of an inverted image), put the grade on an inner group and the post on a group around it:

```odin
if fx.group({post = fx.dither(3)}) {
	if fx.group({gray = 1, contrast = 0.4}) {
		fx.footage("assets/clip.mp4", s.lt, fx.stage())
	}
}
```

Both halves below invert and duotone the same picture. On the left one group does both, so the invert comes last and turns the duotone's colors over. On the right the invert is inside.

```odin
post_order :: proc(s: fx.Shot) {
	picture :: proc(x: f32, t: f32) {
		fx.rect_paint({x, 0, 960, 1080}, fx.linear({x, 0}, {x, 1080}, 0xff101820, 0xff9aa4b0))
		c := fx.Vec2{x + 480 + 160 * math.sin(t * math.TAU / 4), 430}
		fx.circle_paint(c, 230, fx.radial(c - {80, 90}, 400, 0xffffffff, 0xff8c8c8c, 0xff101010))
	}
	duo := fx.duotone(fx.theme.night, fx.theme.na)
	// one group: the duotone runs first, then the invert turns its colors over
	if fx.group({invert = 1, post = duo, clip = fx.Rect{0, 0, 960, 1080}}) do picture(0, s.lt)
	// two groups: the inner one inverts the picture, the outer one colors the result
	if fx.group({post = duo, clip = fx.Rect{960, 0, 960, 1080}}) {
		if fx.group({invert = 1}) do picture(960, s.lt)
	}
	fx.rect({0, 860, 1920, 220}, fx.theme.night)
	fx.label("{invert, post}", {480, 970}, fx.mono(44), fx.theme.nt, {0.5, 0.5})
	fx.label("{post} around {invert}", {1440, 970}, fx.mono(44), fx.theme.nt, {0.5, 0.5})
}
```

The same goes for two filters: the inner group's runs first.

## What it costs

Where frames are drawn on the GPU (the editor's preview, and this page) none of this is worth thinking about. A render draws on the CPU, and there a post filter is one full pass over the group's pixels for every time it reads `src`. On one thread at 1080p a filter that reads each pixel three times takes about 0.05 s a frame, against roughly 2 ms for a frame of ordinary text and shapes. Glow is made of Skia's own blur and costs about 0.02 s.

| Reads per pixel | Filters |
| --- | --- |
| 1 | `pixelate`, `duotone`, `scanlines`, `kaleido`, `warp`, `stretch`, `halftone` and `dither` at `amount = 1` |
| 2 | `halftone` and `dither` while blending in |
| 3 | `rgb_split`, `glitch`, `lens`, `shockwave` |
| 12 | `zoom_blur` |

Keep filters to the frames that need them (let the amount fall to 0 and the filter is gone), and put them on the smallest group that will do. A film-wide `lens` and `glow` on the master group is fine: the fable film has them on nearly every one of its 3,600 frames.

## Reference

| Procedure | Returns |
| --- | --- |
| `rgb_split(px, angle)` | Red and blue pulled `px` apart along `angle` degrees. |
| `glitch(amount, seed)` | Shoved bands and split colors, re-rolled 24 times a second. `amount` 0..1. |
| `zoom_blur(center, amount)` | Radial blur toward `center`. `amount` 0..1 of the way there. |
| `pixelate(px)` | Square pixels `px` wide. |
| `duotone(dark, light)` | Brightness mapped onto a gradient from `dark` to `light`. |
| `scanlines(px, amount)` | Horizontal lines every `px`, darkening by `amount`. |
| `halftone(cell, angle, amount)` | Dots `cell` apart on a grid turned by `angle` degrees, on black. |
| `dither(px, dark, light, levels, amount)` | 8×8 ordered dither in `px` pixels, `levels` shades. |
| `lens(distort, chroma, vignette)` | Barrel distortion, color fringes of `chroma` px, darkened edges. |
| `shockwave(center, radius, width, strength)` | A ring pushing pixels outward by `strength` px. |
| `kaleido(center, n, angle, zoom)` | `n` mirrored repeats around `center`. |
| `warp(amount, scale, speed, seed)` | Flowing noise displacement of `amount` px. |
| `stretch(edge, horizontal, forward)` | The row or column at `edge` smeared over one side. |
| `post(sksl, radius, uniforms…)` | A `Post` from your own SkSL. |
| `glow(radius, amount, threshold, streak)` | A `Glow` for `Xf.glow`. |
| `unpack(color)` | The color as `RGBA{r, g, b, a}` in 0..1, for uniforms. |
| `grade_matrix(xf)` | The 4×5 color matrix of an `Xf`'s grade, and whether it changes anything. Groups call it for you. |
