Log inGet started
World

Procgen Effects Showcase

Branchmain
Branchesmain
Commit99ff90d12c

README.md

DragonBreathDirector

DragonBreathDirector sits on the entity that runs the dragon-breath Generator and keeps three things in step with that generator's clock: the sync_time property of a material, a set of flickering point lights that ride along the fire jet, and playback of the generator itself. The fire, the light it throws and the scorch it leaves on the ground all read the same clock, so they agree.

The fx_breath scene uses it on the dragon_breath entity, next to that entity's Generator, with material set to courtyard_flagstone (a material on the flagstone_scorch shader), mouth at { x = 170, y = 2.4, z = 141 } and frameCamera off. The jet sweeps as yaw(t) = amplitude * sin(2 * pi * t / period), measured from world +Z toward +X; the source states that these sweep constants must match proc/dragon_breath.procGraph and flagstone_scorch.shader.

It needs a Generator component on its own entity. It runs at executionOrder = 50.

Fields

FieldTypeDefaultDescription
materialassetRef (material)nilMaterial whose sync_time follows the breath's clock.
mouthvec3{ x = 0, y = 2.4, z = -9 }World position of the dragon's mouth, metres.
amplitudenumber0.72Half-width of the sweep, radians.
periodnumber14.0Seconds for one full left-right-left sweep.
lightCountnumber4Firelight point lights riding the jet.
frameCamerabooltrueOpen the player's orbit camera on the wide hero shot.
cameraDistancenumber18Orbit distance of the opening shot, metres behind the avatar.
cameraHeightnumber6Height of the opening shot above the avatar's feet, metres.
cameraAimnumber2Height above the avatar's feet the opening shot looks at, metres.

All fields are NoSync.

Lifecycle

  • awake(): binds the Generator on its entity and the material asset, then builds the lights. It despawns every entity matching dragon_firelight_* and spawns lightCount temporary entities named dragon_firelight_1, dragon_firelight_2 and so on, each with a point Light (colour { 1.0, 0.42, 0.1 }, intensity 0, range 14, shadows off).
  • start(): calls play() on the Generator.
  • update(dt): runs the per-frame drive described below.
  • editorUpdate(dt): runs the same drive while engine.paused is true.
  • onDestroy(): despawns the lights it spawned.

Each drive step:

  1. When frameCamera is on, every 0.5 seconds it looks for entities named CameraRig that carry a controller.orbital_follow component and, once per rig, sets maxRadiusScale = 6, ringCenter = { height = cameraHeight, radius = 4.5 }, radiusScale = cameraDistance / 4.5 and aimHeight = cameraAim. Each rig is framed once, so the player's own scroll and orbit stay in the player's hands afterwards.
  2. It rebinds the Generator if it has none yet, and rebuilds the lights if the first one is gone.
  3. It reads the generator's time t with getTime() and sets the material's sync_time to t % period, the phase of the periodic sweep.
  4. It computes the sweep yaw and places light i of n along the jet, at 1.5 + 13 * (i / n) from the mouth and 1.5 * (i / n) below it (held at a height of at least 0.9). Each light's intensity is (60 - 34 * (i / n)) scaled by its own sum-of-sines flicker, and its radius is 12 + 10 * (i / n).