# Stylise

Make flat art read as inked and printed - hatching, ink outlines, paper, halftone, speckled colour, line boil and light shafts.

`post.stylise` draws over the finished frame the way a printmaker would: hatching in the shadows, ink on the edges, paper under everything. Simple flat shapes (an [SVG drawing](/docs/features/svg), vector shapes, unlit materials) come out looking hand made. Every effect is 0 (off) until you set it.

```jsonc
"post": {
  "tone_mapping": "none",
  "stylise": {
    "hatch": 0.6, "hatch_threshold": 0.45, "cross_threshold": 0.22,
    "ink": 0.45, "paper": 0.6,
    "posterize": 12, "dither": 0.9,
    "boil": 1.1, "boil_fps": 12
  },
  "rays": {"from": [0.5, 0.45], "strength": 1.4, "threshold": 0.7, "color": "#ffc070"}
}
```

## Hatching

`hatch` lays parallel ink strokes wherever the image is darker than `hatch_threshold` (luminance 0..1). Strokes thicken as it gets darker, waver a little and break where the pen lifted. Below `cross_threshold` a second set crosses them. `hatch_scale` is the stroke spacing and `hatch_angle` the direction. `hatch_follow` (0..1) bends the strokes to run along the forms: around outlines and through soft shading, the way a pen follows a cheek or a fold. Paint the shading in (soft gradient shapes on the shadow side) and the hatching follows it.

## Ink, Paper and Print

- `ink`: outlines drawn wherever colour changes sharply, `ink_width` wide, in `ink_color`. On art that already has outlines it thickens and roughens them.
- `paper`: fibres, blotches and a warm tint that break up flat fills. `paper_scale` sizes them.
- `halftone`: printed dots that grow in the shadows (`halftone_scale` apart).
- `posterize`: reduce colour to this many steps. Add `dither` (0..1) to speckle the steps with noise: soft gradients like a blush or a glow turn into grainy, printed-looking dots.
- `ramp`: a gradient map `[dark, light]`, mixed in by `ramp_amount`.

## Line Boil

`boil` wobbles the whole frame by a few pixels, re-drawn `boil_fps` times a second (12 is on twos). The hatching and paper jitter with it, so a still drawing looks freshly traced on every frame. For noise on one value (a hand-held camera, a flickering lamp), use a track's [`wiggle`](/docs/features/timeline).

## Light Shafts

`post.rays` streams light from a point on screen (`from`, `[0, 0]` top left to `[1, 1]` bottom right) through everything brighter than `threshold`: rays through a doorway, sun through mist. `length` is how far they reach and `color` tints them.

## Keeping Captions Crisp

Set `"overlay": true` on a node (a caption, a title, a logo) to keep it and its children out of `stylise` and `rays`: it is drawn after them, sharp and on top of everything, with the same tone mapping and grade. Depth of field and line boil don't touch it either.

## Per Shot

A [shot](/docs/features/shots) can carry its own `stylise` and `rays`: they replace the scene's while that shot plays, so a soft close-up and a hatched wide shot can share one scene.

## In TypeScript

`inked(overrides)` from `@motion-sdk/scene` returns the look above as a starting point, and `wiggle(amount, options)` builds a track's wiggle:

```ts
import { inked, track, wiggle } from "@motion-sdk/scene";

const post = { tone_mapping: "none", stylise: inked({ hatch: 0.8 }) };
const shake = track("camera_rig", "rotation", [], { wiggle: wiggle([0, 0, 1.5], { frequency: 4 }) });
```

## Where it Runs

Native rendering and export (the CLI) have it, and in the browser the authoring bundle and the WebGL2 fallback do: `createPlayer` loads the authoring bundle for any scene that uses `stylise`, `rays`, `overlay` or `wiggle`. The small WebGPU player bundle leaves it out.

For a low-resolution game look with a fixed palette, see [Pixel Art](/docs/features/pixel-art).

## API Reference

### Stylise

Hand-drawn look applied to the whole frame after tone mapping. Every effect is off at 0, so set only the ones you want.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `boil` | `number (0 to 16)` | `0` | Line boil: the frame wobbles by up to this many pixels (at 1080p height), re-drawn `boil_fps` times a second, like hand-drawn lines traced again on every drawing. 0 = off. |
| `boil_fps` | `number (1 to 60)` | `12` | How often the boil (and the hatch and paper jitter) changes. |
| `cross_threshold` | `number (0 to 1)` | `0.22` | Luminance below which a second, crossing set of strokes is added. |
| `dither` | `number (0 to 1)` | `0` | Speckle the steps of `posterize` with noise, 0..1, so soft gradients (blush, glow) break up into grainy, printed-looking dots. |
| `halftone` | `number (0 to 1)` | `0` | Halftone dots in the mid tones and shadows, 0..1. |
| `halftone_scale` | `number (2 to 64)` | `8` | Dot grid spacing in pixels at 1080p height. |
| `hatch` | `number (0 to 1)` | `0` | Ink hatching in the shadows, 0..1: parallel strokes whose width grows as the image gets darker. |
| `hatch_angle` | `number` | `35` | Stroke direction in degrees (0 = horizontal). |
| `hatch_follow` | `number (0 to 1)` | `0` | How much hatching turns to follow the forms, 0..1: strokes bend to run along shapes' outlines and shading (like a pen following a cheek or a fold) instead of all lying at `hatch_angle`. |
| `hatch_scale` | `number (2 to 64)` | `7` | Spacing between hatch strokes in output pixels at 1080p height. |
| `hatch_threshold` | `number (0 to 1)` | `0.45` | Luminance (0..1) below which hatching starts. |
| `ink` | `number (0 to 1)` | `0` | Ink outlines found from edges in the frame, 0..1. |
| `ink_color` | `Color` | `"#120b14"` | Ink color for strokes, outlines and halftone dots. |
| `ink_width` | `number (0.5 to 8)` | `1.5` | Outline width in pixels at 1080p height. |
| `paper` | `number (0 to 1)` | `0` | Paper texture, 0..1: fibres and blotches that tint and break up flat fills. |
| `paper_scale` | `number (0.1 to 10)` | `1` | Paper texture size (1 = default). |
| `posterize` | `integer (0 to 16)` | `0` | Reduce each channel to this many levels (0 = off, 2..16). |
| `ramp` | `Color[]` | — | Gradient map: luminance remapped from `[dark, light]`, mixed in by `ramp_amount`. |
| `ramp_amount` | `number (0 to 1)` | `1` | How much of the gradient map to mix in, 0..1. |
### Rays

Light shafts (god rays) streaming from a point on screen through the bright parts of the frame.

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `color` | `Color` | `"#ffffff"` | Tint of the shafts (white keeps the source colours). |
| `from` | `[x, y]` | `[0.5,0.3]` | Light position on screen: `[0, 0]` top left, `[1, 1]` bottom right (may lie outside the frame). |
| `length` | `number (0 to 1)` | `0.6` | How far the shafts reach, as a fraction of the way to the light. |
| `strength` | `number (0 to 4)` | `1` | Brightness of the shafts, 0..4. |
| `threshold` | `number (0 to 4)` | `0.7` | Luminance above which pixels cast shafts. |
