Skip to content

StarSkyEffect

Source: StarSkyEffect.h

StarSkyEffect

class StarSkyEffect
src/light/effects/StarSkyEffect.h:24

Inherits: EffectBase

Night-sky effect: twinkling stars over a dark field.

StarSkyEffect card StarSkyEffect controls Author: limpkin (MoonLight), https://github.com/ewowi/MoonLight/blob/main/src/MoonLight/Nodes/Effects/E_MoonLight.h

A pool of stars, sized from the light count, each taking a random cell and brightness. Every frame a star steps toward full and reverses, or toward zero and respawns elsewhere. A small per-frame chance flips its direction early, so the field never pulses in sync.

Prior art: MoonLight's StarSky, whose pool model and early reverse this reproduces.

Public Attributes

uint8_t speed = 1 : How far a star's brightness steps each frame.

uint8_t star_fill_ratio = 42 : Stars per ten thousand lights, which sizes the pool.

bool usePalette = false : Give each star its own palette color rather than white.

Public Methods

virtual inline const char * tags() const override : Catalog tags: MoonLight origin.

virtual inline Dim dimensions() const override : A star takes any cell of the volume.

virtual inline void defineControls() override : Publish the twinkle rate, the star density and the coloring.

virtual inline void prepare() override : Size the per-star arrays on the heap, since an inline one overflows the probe's stack.

virtual inline void tick() override : Dim the sky, then step and draw every star.

More info

The color leads the step

Each frame reads a star's brightness, makes its color, then steps that brightness. So the color drawn is the one from before this frame's step, as the source does it. Stars are white unless usePalette, where each carries a palette index of its own.