Stylize: turns a generator's smooth geometry into the meshes the stylised
looks draw. Bake-time only (ArcticBake calls it).
local St = require("~.Stylize")
local low = St.facet(geo, { jitter = 0.08, seed = 3 }) -- lowpoly: flat-shaded facets
local px = St.voxel(geo, 0.1, { palette = 6 }) -- pixel: a blocky voxel shell
local ink = St.inkHull(geo, 0.02) -- cartoon: inverted hull outline
facet: every triangle gets its own three vertices and its face normal, so the
shading breaks into flat planes; each face takes one flat colour (the mean
of its corners, nudged by a seeded jitter), the "low-poly" read.
voxel: samples every triangle onto a grid of `size` metre cells, fills the
inside (flood fill from outside), and emits only the cell faces between a
filled cell and outside air. Each face is a quad in the cell's quantised
colour, UVs planar in cells so a pixel-art texture lands one texel run per
block. Thin parts (blades, petals, flags) become one-cell sheets.
inkHull: the shell of the surface pushed out along welded normals by `thick`
metres, with inward normals and winding (so only its far inside draws
behind the prop: a dark rim on every silhouette), vertex colour near black.
facet(g: any, o: any?) → any
Flat-shaded copy: unshared vertices, face normals, one colour per face (jitter 0..1 varies it per face).
| arg | type | description |
|---|
| g | any | |
| o | any? | |
weld(g: any, eps: number) → any
Merge vertices closer than eps (keeps the first one's attributes); returns a new indexed Geo. Used to make a cheap low-poly cage before faceting.
| arg | type | description |
|---|
| g | any | |
| eps | number | |
voxel(g: any, size: number, o: any?) → void
Voxelise g into cubes of `size` metres. Opts { palette = levels per channel (default 6), maxCells }. Returns Geo, cell count.
| arg | type | description |
|---|
| g | any | |
| size | number | |
| o | any? | |
id(i: number, j: number, k: number) → number
| arg | type | description |
|---|
| i | number | |
| j | number | |
| k | number | |
mark(x: number, y: number, z: number, r: number, gg: number, b: number, a: number) → void
| arg | type | description |
|---|
| x | number | |
| y | number | |
| z | number | |
| r | number | |
| gg | number | |
| b | number | |
| a | number | |
push(i: number, j: number, k: number) → void
| arg | type | description |
|---|
| i | number | |
| j | number | |
| k | number | |
quant(v: number) → number
| arg | type | description |
|---|
| v | number | |
voxelParts(geos: { any }, size: number, o: any?) → void
Voxelise several parts on ONE grid of `size` metre cells: each cell belongs to the part with the most surface in it, so parts never interleave. Returns one Geo per input (same order). Opts { palette = levels per channel }.
| arg | type | description |
|---|
| geos | { any } | |
| size | number | |
| o | any? | |
id(i: number, j: number, k: number) → number
| arg | type | description |
|---|
| i | number | |
| j | number | |
| k | number | |
quant(v: number) → number
| arg | type | description |
|---|
| v | number | |
isOutside(i: number, j: number, k: number) → boolean
| arg | type | description |
|---|
| i | number | |
| j | number | |
| k | number | |
voxelFit(g: any, n: number, budget: number, o: any?) → void
Voxelise with the largest cell count that stays under `budget` triangles: starts from `n` cells across the longest side and coarsens. Returns Geo, cell size.
| arg | type | description |
|---|
| g | any | |
| n | number | |
| budget | number | |
| o | any? | |
inkHull(g: any, thick: number) → any
Inverted-hull outline: g pushed out by thick metres along welded normals, winding and normals turned inward, vertex colour near black.
| arg | type | description |
|---|
| g | any | |
| thick | number | |
flatPixels(geos: { any }, size: number, o: any?) → void
Pixel look for flat decals (cracks lying on ice): every part rasterised onto ONE flat grid of `size` metre cells seen from above (a cell belongs to the first part that covers it), emitted as merged up-facing quads one cell wide at the part's own height, colour quantised. Returns one Geo per input. Opts { palette = levels per channel }.
| arg | type | description |
|---|
| geos | { any } | |
| size | number | |
| o | any? | |
quant(v: number) → number
| arg | type | description |
|---|
| v | number | |