About this simulation

This simulation recreates a bioluminescent firefly swarm drifting through a warm summer night. Each of the up to 2,000 individual fireflies follows its own sinusoidal drift path and blinks independently, producing the characteristic out-of-phase shimmer you see in real meadows. The glow is rendered with custom GLSL shaders and additive blending so the soft halos layer realistically against the dark sky โ€” just like the cold chemical light produced deep inside a living beetle's abdomen.

๐Ÿ”ฌ What it shows

Each particle represents one firefly executing a Lissajous-like drift driven by its own random speed and phase offset. The blink intensity is computed per-particle in the vertex shader using a sine wave, so no two fireflies flash in unison โ€” mirroring the asynchronous (and occasionally synchronised) behaviour seen in nature. Three colour modes let you explore warm yellow-green, pure green, and blue-twilight bioluminescence.

๐ŸŽฎ How to use

Use the sliders to change firefly count (100โ€“2,000), glow size, blink rate, and drift speed. Pick a colour preset with the buttons below. Click and drag on the canvas to orbit the swarm; scroll to zoom. Toggle Auto-rotate for a hands-free view, or hit Reset view to snap back to the default camera position.

๐Ÿ’ก Did you know?

Firefly light is nearly 100 % efficient โ€” almost no energy is lost as heat. The reaction requires luciferin, the enzyme luciferase, ATP, and oxygen. Some species, notably Photinus carolinus in the Great Smoky Mountains, synchronise their flashes across entire hillsides; scientists believe this helps males stand out to females during the brief mating season.

Frequently asked questions

How do fireflies produce light?

Fireflies use bioluminescence: a cold chemical reaction inside specialised cells in their abdomen called photocytes. Oxygen combines with luciferin in the presence of the enzyme luciferase and an energy molecule (ATP), releasing a photon of yellow-green light. Because almost no heat is produced, it is one of the most efficient light sources in nature โ€” roughly 96 % of the energy becomes visible light.

Why do fireflies blink out of phase with each other?

Each firefly has its own internal oscillator โ€” a neurological pacemaker that controls when its photocytes fire. The period and phase of that oscillator vary between individuals, so in a large swarm the flashes appear random. In this simulation the same principle is modelled with a sine wave: every particle has a unique random phase offset (aPhase) and speed (aSpeed), ensuring no two fireflies peak at the same moment.

Do some fireflies really synchronise?

Yes. Species such as Photinus carolinus (USA) and Pteroptyx tener (South-east Asia) spontaneously synchronise โ€” all males in a tree or meadow flash in near-perfect unison. The leading hypothesis is that each firefly acts as a coupled oscillator: it slightly adjusts its own rhythm when it perceives a neighbour's flash, and over several minutes the whole population locks in phase. The "Blue twilight" colour mode in this simulation is a nod to the rarer bioluminescent species that emit shorter-wavelength light.

What controls the size and brightness of the glow?

In the simulation, glow size is the uGlowSize uniform, which scales the gl_PointSize in the vertex shader. Brightness is governed by vBlink โ€” the per-particle sine value clamped to 0โ€“1 โ€” which drives both the colour mix and the alpha of a Gaussian soft-glow computed in the fragment shader (exp(-distยฒ ร— 14)). In real fireflies, flash brightness and duration are species-specific and can also be affected by temperature.

Can I slow the simulation down to study individual blinks?

Absolutely. Drag the Blink rate slider all the way left (minimum 0.2ร—) and the Drift speed slider to its lowest value (0.1ร—). Then use the orbit controls to zoom right in on a small cluster of fireflies. At low blink rate each particle's sine oscillation is slow enough to watch the warm glow build up and fade on a single "firefly" โ€” the same on/off cycle that lasts roughly 0.5โ€“1 second in the wild.