NebulaEffect
Source:
NebulaEffect.h
NebulaEffect¶
src/light/effects/NebulaEffect.h:27Inherits:
EffectBase
Effect: a noise field births light, a curl flow carries it, and the two make a folding cloud.
Prior art: Stefan Petrick's shader vocabulary, and Bridson's curl noise (SIGGRAPH 2007).

Built from two power functions rather than one, which is what makes it a nebula. A noise field decides where light is born, thresholded so only its top survives. A curl flow decides where that light goes, and being divergence-free nothing piles up. The emitter is a field rather than a handful of dots, so light enters everywhere at once.
Public Attributes¶
uint8_t speed = 40
: How fast the medium moves, and with it the whole cloud.
uint8_t scale = 40
: The field's cell size. Low gives broad clouds, high gives wisps.
uint8_t contrast = 192
: The birth window, placed against the field's own range so it means the same on any fixture.
uint8_t persistence = 140
: How long light survives once it is in the flow.
uint8_t octaves = 2
: Detail in the field, and its cost knob.
uint8_t fieldScale = 1
: The field's resolution: 1 is full, 2 half, 4 quarter.
uint8_t fieldRate = 1
: Recompute the field every N frames.
Public Methods¶
virtual inline const char * tags() const override
: Catalog tags: this effect is the power-function showcase.
virtual inline Dim dimensions() const override
: Volumetric: the flow and the field both carry z.
virtual inline void defineControls() override
: Publish the flow, the field's shape, the birth window and the two cost levers.
virtual inline bool affectsPrepare(const char * name) const override
: Only fieldScale resizes anything, so only it forces a rebuild.
inline uint8_t fieldScaleClamped() const
: The lever, clamped once: [prepare()] sizes the field from it and [tick()] picks its path by it.
virtual inline void prepare() override
: Size both cloud planes, the field at its own resolution, and everything the render path writes.
virtual inline void tick() override
: Carry the cloud along the curl flow, decay it, then birth new light into it.
More info¶
Two cost levers¶
The field is the expensive half, and both levers cut it while leaving the motion alone. fieldScale computes the field at half or quarter resolution and stretches it. fieldRate recomputes it every N frames instead of every frame. The flow still carries the plane each frame, so a cheaper field costs detail, not smoothness.
Cost: one curl per light per frame, and one fbm per light at whatever the levers ask for.