# RiftFlicker
RiftFlicker drives a Light's intensity so it breathes, flickers and surges with the arcane rift. It
sits on an entity with a `Light` component and sets that light's `intensity` every frame. It is a
local-only visual: its fields are `NoSync`, and every peer runs its own flicker.
The fx_rift scene uses it on four lights. `rift_heart_light` runs the defaults. `rift_rim_light_1`,
`rift_rim_light_2` and `rift_rim_light_3` run `base = 9`, `breathe = 0.05`, `flicker = 0.3`,
`flickerRate = 17`, `surge = 0.4` and `surgeRate = 3.3`, with phases 0.37, 0.74 and 1.11 so they
pulse out of step.
It runs at `executionOrder = 0`.
## Fields
| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `base` | number | 18 | Intensity the light sits around, in the Light component's units. |
| `breathe` | number | 0.1 | Share of base the slow breathing swings by. |
| `flicker` | number | 0.15 | Share of base the fast noise flicker swings by. |
| `flickerRate` | number | 11 | How fast the flicker noise changes, in cycles per second. |
| `surge` | number | 0.45 | Share of base a surge adds at its peak. |
| `surgeRate` | number | 2.1 | Angular rate of the surge cycle, in radians per second (matches the spark bursts). |
| `phase` | number | 0 | Offset into the cycle, in seconds, so several lights do not pulse in lockstep. |
## How the intensity is computed
With `t` the component's own running clock plus `phase`:
```
s = max(0, sin(t * surgeRate))
k = 0.78 + breathe * sin(t * 1.7)
+ flicker * math.noise(t * flickerRate, phase * 3.1)
+ surge * s^12
intensity = base * max(k, 0.2)
```
## Lifecycle
- `update(dt)`: advances the clock by `dt` and sets the light's intensity.
- `editorUpdate(dt)`: does the same while `engine.paused` is true, so edit-running ticks it once per
frame.
# rift_ground
Ground material for the arcane rift scene `fx_rift`. The scene's `ground` entity (a built-in cube
scaled 70 x 0.2 x 70 at (-150, -0.1, 140)) wears it. mat.yaml describes it as "Dark scorched basalt
around the arcane rift."
Shader: `rift_ground` (`rift/shaders/rift_ground.shader`). Its README: dark basalt ground for the
arcane rift, procedural mottled slabs with bump lighting, scorched and heat-glowing around a rift
centre. From the shader: slabs are separated by Voronoi gaps that darken the albedo and the
occlusion; the scorch makes the stone darker and smoother near the centre, over an ellipse stretched
1.5 times along x because the rift runs along x; the heat glow is strongest at the centre and in the
slab gaps near it, and breathes over time. It shades its own fragments through the shared
`pbr_shading` model.
Render state (the `render` block of mat.yaml): `queue: 2000`, `type: opaque` (opaque blend), `cull:
back`.
## Properties
- `base_color: [0.16, 0.15, 0.17, 1]`: stone albedo before mottling, grain and scorch (default
[0.11, 0.1, 0.12, 1]).
- `center: [-147.5, 0, 148]`: world position of the rift; the shader uses its x and z. The mat.yaml
comment ties it to the `ArcaneRift` entity in `scenes/fx_rift.scene`, which stands at (-147.5, 0,
148).
- `glow: [0.55, 0.12, 1, 1]`: emissive colour of the heat glow, a purple.
- `glow_strength: 1.0`: multiplier on the glow.
- `bump: 0.25`: strength of the bump normal from the slab height field (default 0.35).
# arcane_rift
A rift tearing open in the ground: a glowing mouth along a crack in the earth, cracks branching
out from it, rubble heaving up, sparks and streaks climbing out of it, motes drifting above and a
plume rising from it. It is centred on the generator's origin with its long axis along x and the
ground at y = 0.
```lua
-- `graph` is this graph's reference: the AssetRef `asset.resolve` or a search returns for it.
local e = entity.spawn("arcane_rift", { position = { 0, 0, 0 } })
e.component.add("Generator", { graph = graph, playOn = "load", ending = "loop" })
```
| Input | Default | What it does |
|---|---|---|
| `intensity` | 1 | Brightness of everything that glows: the mouth, cracks, sparks, streaks, motes and plume (0 to 4). |
| Output | What it draws |
|---|---|
| `mouth` | The glowing opening, `rift_core` shader |
| `cracks` | The cracks branching out across the ground, `rift_crack` shader |
| `rubble` | Rubble around it, `rift_rock` shader, moved by the `rift_rubble` compute shader |
| `sparks` | Sparks thrown from the mouth, `rift_streak` shader |
| `streaks` | Streaks climbing out of it, `rift_streak` shader |
| `motes` | Motes drifting above it, `rift_mote_cluster` shader, moved by the `rift_motes` compute shader |
| `plume` | The plume rising from it, `rift_plume` shader |
The timeline has no end and plays at 60 fps.
# effectShowcase
The procedural effects of the Procgen Effects Showcase world. Each one is a `.procGraph` that plays
through a `Generator`, and every shader, material and module a graph draws with sits beside it in
this package, so the package carries everything its graphs need. Each graph's README says what it
makes, how to place it and what each of its inputs changes.
## Contents
| Folder | Graphs | What they make |
|---|---|---|
| `combat/` | `impact`, `muzzleFlash`, `tracer` | A round striking a hard surface, the bloom at a barrel as a weapon fires, and the glowing streak of a round in flight. They draw with `fxFlash`, `fxSmoke` and `fxSpark` in `combat/shaders/`. |
| `blast/` | `wall_blast` | A charge blowing a breach through a stone block wall, on a 9.6 s loop. |
| `storm/` | `storm`, `tower` | A thunderstorm around a lone tower: wind-driven rain, lightning striking on the schedule `schedule.module` keeps, and sparks and smoke where strikes land. `tower` is the stone keep it stands around. |
| `rift/` | `arcane_rift` | A rift tearing open in the ground, its motes and rubble moved by the compute shaders in `rift/compute/`. |
| `dragon/` | `dragon_breath` | A dragon's fire breath sweeping a courtyard: a flame jet, rolling smoke and drifting embers. |
| `launch/` | `launch` | A heavy-lift rocket liftoff on one looping timeline, with the heat-haze material `rk_haze_mat`. |
| `waterfall/` | `wf_env`, `wf_water`, `wf_spray`, `wf_foam`, `wf_mist` | A waterfall built in parts: the cliff, basin and boulders, the falling and still water, the droplets, the foam where the falls land, and the mist with its rainbow. Its water materials are in `waterfall/materials/`. |
| `shaders/` | | `fx_noise`, the noise functions the waterfall and wall blast shaders include. |
## Playing one
A graph plays on a `Generator` component bound to it:
```lua
-- `graph` is the graph's reference: the AssetRef `asset.resolve` or a search returns for it.
local e = entity.spawn("impact", { position = { 0, 1, 0 } })
e.component.add("Generator", { graph = graph, playOn = "load" })
```
Set a graph's inputs with the Generator's `params`, e.g. `params = { size = 3 }`.