# render

Part of the [scripting reference](index.md), written by the engine so it matches your `frost`. Start with [your first game](../start/first-game.md) if you are new.

Use when configuring bloom, materials, frame graphs or effects, or diagnosing rendering such as why a pixel is dark.

```toml
# Optional frame graph. Omitted: all layers into `frame` in 2D; sky if present,
# meshes, then layers in 3D. Named `targets`: `format` "rgba8" (default), "rgba16f"
# or "depth"; `size` "frame" (default), "frame/N" (N 2..16), or a pixel side length.
# Each named pass writes `into` a target (default `frame`) and either draws or runs
# an effect on its `read` targets. Draws: "layers", from `from` to `to` inclusive
# (default all); in 3D, "meshes" (lit, tested against its `depth` target) or "sky"
# (the world's Sky over the target; put before meshes). First writes clear; work
# never reaching `frame` is dropped. `render.passes` lists the running graph.
# Effects: "copy"; "bright", above `threshold` (0.6); "blur"; "add", second target
# added `strength` times (1) to first (float targets keep values above 1); "panini", distance `strength` (0 none),
# bending a wide 3D view to fill, keeping its middle. A `Pass` sets numbers each frame.
# `bright` into rgba16f keeps radiance above a nonnegative threshold, including 1.
# Into rgba8 its threshold must be below 1; it normalizes by (1 - threshold).
# "aces": exposure `strength` (default 1, nonpositive 0), then ACES fitted curve,
# then sRGB. Requesting it enables linear mesh/sky output above 1 into rgba16f,
# including emission, fog and blending. Without it, existing graphs stay unchanged.
# Draw sky/meshes into rgba16f, read that with aces, draw layers afterward (UI/text
# unchanged): the engine's torch/tonemap.toml. example WebGL2 needs renderable/filterable/blendable
# half-float support (E0208 otherwise). frame.at names presentation unread.
# `materials` (3D, alone or with passes): `vertex` and/or `fragment` WGSL files for
# Mesh (see Meshes). `bloom = { threshold = 0.85, strength = 1.5 }` (defaults; alone
# or with materials) softens brightness above threshold (0..1), adding it strength
# times. Generated passes `bright`, `soften`, `bloom` accept Pass numbers. All 2D
# blooms; in 3D, sky/meshes bloom, overlay layers do not. Custom passes cannot use
# this shorthand: place bright/blur/add there yourself.
# `ao = { radius = 1, strength = 1 }` (defaults; 3D, alone or with any of the above,
# custom passes included): ambient occlusion. Where surfaces within `radius` metres
# (0..100] close a point in (a corner, a crate on a floor), the ambient light and the
# sky a metal mirrors darken, up to `strength` (0..1). Sun, lamps, shadows, emission
# and layers are untouched. It adds passes `ao_seen`, `ao_occlude` (a Pass sets radius
# and strength) and `ao_soften` before the first meshes pass, with targets `ao`,
# `ao_distance`, `ao_depth`, `ao_rough`. Fixed sample pattern: no shimmer, one picture
# every run. Screen-space: what is hidden or off screen shades nothing; see-through and
# masked parts shade nothing. frame.at names it unread. See the engine's ao. example
# `effects` (up to 8): `name = { file = "x.wgsl", reads = 1 }` (1 or 2). The file's
# `fn effect(at: vec2<f32>, size: vec2<f32>, threshold: f32, strength: f32) -> vec4<f32>`
# returns colour at pixel centre `at` in target `size` (pixels), in the target's encoding.
# Read helpers: one(px), two(px) (whole pixels, same bytes across backends),
# under_one(at), under_two(at), one_size(), one_soft(uv), two_soft(uv) (between pixels),
# lens(). No clock: animate via Pass numbers. Start from the engine's functions
# in crates/frost_gfx/src/effects/. Compilation errors name file/line (E0456).
[render]
# Optional: msaa = 4 (default 1); sky/meshes first, resolve before effects/UI.
# A smoothed edge's pixel may be one level off in WebGL2 (its own rounding).
# cull = true and samplers = true follow glTF sides and filters (both default false).
# HDR resolves rgba16f before aces, then UI; see the engine's edges/tonemap.toml. example
targets = { scene = {}, glow = { size = "frame/4" }, soft = { size = "frame/4" } }
passes = [
    { name = "world", draw = "layers", to = 99, into = "scene" },
    { name = "bright", effect = "bright", read = ["scene"], into = "glow" },
    { name = "soften", effect = "blur", read = ["glow"], into = "soft" },
    { name = "bloom", effect = "add", read = ["scene", "soft"] },
    { name = "ui", draw = "layers", from = 100 },
]
```
