|
| 1 | +# EPU Environments |
| 2 | + |
| 3 | +The Environment Processing Unit (EPU) is ZX’s procedural background + ambient environment system. |
| 4 | + |
| 5 | +- It renders an infinite environment when you call `draw_env()`. |
| 6 | +- The same environment is sampled by lit shaders for ambient/reflection lighting. |
| 7 | + |
| 8 | +For exact function signatures, packed layouts, and parameter docs, see the [Environment (EPU) API](../api/epu.md). |
| 9 | + |
| 10 | +--- |
| 11 | + |
| 12 | +## Quick Start |
| 13 | + |
| 14 | +1. Configure the **base layer** (layer `0`) with an `env_*` function. |
| 15 | +2. Optionally configure the **overlay layer** (layer `1`). |
| 16 | +3. Set how the overlay composites with `env_blend()`. |
| 17 | +4. Call `draw_env()` in your `render()` function. |
| 18 | + |
| 19 | +Tips: |
| 20 | +- Start from the inspector presets, then tweak `density/intensity/colors`. |
| 21 | +- Animate with `phase` (wraps as u16) using `wrapping_add()` in your game code. |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## Mode Overview |
| 26 | + |
| 27 | +| Mode | Name | Best for | Common role | |
| 28 | +|---:|---|---|---| |
| 29 | +| 0 | Gradient | Sky/ground anchor + featured sun | Base | |
| 30 | +| 1 | Cells | Particles (stars/snow/rain) and emissive tiles/lights | Overlay (sometimes base) | |
| 31 | +| 2 | Lines | Floors/ceilings, scanlines, speed streaks | Overlay | |
| 32 | +| 3 | Silhouette | Mountains/city/forest/waves on the horizon | Base | |
| 33 | +| 4 | Nebula | Fog/clouds/aurora/ink/plasma/abstract space | Base or overlay | |
| 34 | +| 5 | Room | Indoor “box” environments | Base | |
| 35 | +| 6 | Veil | Drapes/pillars/shards/atmosphere | Overlay | |
| 36 | +| 7 | Rings | Portals/tunnels/radar focal effects | Overlay (sometimes base) | |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +## Common Recipes |
| 41 | + |
| 42 | +- Outdoor day/night: Gradient base + (optional) Cells or Nebula overlay |
| 43 | +- Neon city: Silhouette (City skyline) base + Cells (Tiles/Lights) overlay (Screen/Add) |
| 44 | +- Space: Nebula base + Cells (stars) overlay + Rings overlay |
| 45 | +- Indoor sci-fi: Room base + Lines overlay + (optional) Veil overlay |
| 46 | + |
| 47 | +--- |
| 48 | + |
| 49 | +## Troubleshooting |
| 50 | + |
| 51 | +- Shimmer in reflections: reduce `motion`/high-frequency detail and keep `phase` smooth. |
| 52 | +- Too noisy: reduce `density`, `intensity`, or `contrast`-style controls. |
| 53 | +- Overlay looks wrong: try a different `env_blend()` mode (Alpha/Add/Multiply/Screen). |
| 54 | +- Aliasing: increase thickness/softness-style controls or reduce detail/warp. |
0 commit comments