# Inputs

The built-in values every effect can read, as shader nodes on u and as numbers on input.

Inputs are values Diorama computes for every layer: the pointer, hover, scroll progress, time and more. An effect reads them in two forms. `u.<input>` is a shader node for TSL, and `input.<input>` is the same value as a number for code that runs on the CPU. Input names are never param names.

## Shader nodes

These are the members of `u` besides the params of the effect.

| Name | Type | Description |
| --- | --- | --- |
| `hover` | `UniformNode<'float'>` | Damped 0..1 while the pointer is over the box. 0 under reduced motion. |
| `hoverTime` | `UniformNode<'float'>` | Seconds that run while hovered or while `hover` decays, frozen at rest and under reduced motion. Reading it implies `animate: 'hover'`. |
| `motion` | `UniformNode<'float'>` | 1 normally, 0 under prefers-reduced-motion. Handy as a multiplier. |
| `opacity` | `UniformNode<'float'>` | CSS opacity of the element and its ancestors, times the copy's opacity and presence while taken. The surface applies it and `ctx.mask()` includes it. |
| `pin` | `UniformNode<'float'>` | 0 when the top reaches the viewport top, 1 when the bottom reaches the viewport bottom. |
| `pointer` | `UniformNode<'vec2'>` | Pointer in element UV, y up like `uv()`. 0..1 inside the box, not clamped outside. |
| `pointerWorld` | `UniformNode<'vec2'>` | Pointer in world px on the z = 0 plane. Viewport centre is 0,0, y up. |
| `presence` | `UniformNode<'float'>` | 1 at rest, 0..1 while the copy enters or leaves a page. |
| `progress` | `UniformNode<'float'>` | 0 as the top enters at the bottom of the viewport, 1 as the bottom leaves at the top. |
| `size` | `UniformNode<'vec2'>` | Box size in CSS px. |
| `time` | `UniformNode<'float'>` | Seconds that advance only while visible. Frozen under reduced motion. |
| `velocity` | `UniformNode<'float'>` | Scroll velocity in -1..1 (3000 px/s is 1), positive scrolling down. 0 under reduced motion. |

## Numbers

`input` holds the same values as numbers, plus the box of the element and its visibility. It is one object per layer, updated in place before each frame.

| Name | Type | Description |
| --- | --- | --- |
| `delta` | `number` | Seconds since the previous frame. |
| `height` | `number` | Box height in CSS px. |
| `hover` | `number` | Damped 0..1 hover, like `u.hover`. |
| `hoverTime` | `number` | Seconds while hovered, like `u.hoverTime`. |
| `opacity` | `number` | CSS opacity with the copy's opacity and presence, like `u.opacity`. |
| `over` | `boolean` | Pointer is over the box right now, without damping or reduced motion. |
| `pin` | `number` | Pin progress, like `u.pin`. |
| `pointer` | `{ readonly x: number; readonly y: number }` | Pointer in element UV, y up, like `u.pointer`. |
| `pointerWorld` | `{ readonly x: number; readonly y: number }` | Pointer in world px, like `u.pointerWorld`. |
| `presence` | `number` | 1 at rest, 0..1 while the copy enters or leaves, like `u.presence`. |
| `progress` | `number` | Scroll progress through the viewport, like `u.progress`. |
| `reducedMotion` | `boolean` | The page prefers reduced motion. |
| `time` | `number` | Seconds while visible, like `u.time`. |
| `velocity` | `number` | Scroll velocity in -1..1, like `u.velocity`. |
| `visible` | `boolean` | On screen this frame (box plus bleed, or posed). |
| `width` | `number` | Box width in CSS px. |
| `x` | `number` | Left edge of the box in viewport CSS px. |
| `y` | `number` | Top edge of the box in viewport CSS px. |

## Inputs and frames

Reading an input decides when the effect draws. An effect that reads `u.time` draws every frame while it is on screen, and one that reads `u.hoverTime` draws while the pointer is over it and while hover fades. Any other effect draws when the page scrolls, the pointer moves over it or a param changes. Under reduced motion `hover`, `velocity` and `motion` are 0, and `time` and `hoverTime` stand still.
