Renderer · interface

ParticleInstances

A pool's per-particle stream, as a particle material reads it.

Explained in Hello world.

interface ParticleInstances
import type { ParticleInstances } from '@driftengine/core';

In depth

Separate from InstanceData — which is a scatter stream, built for placing thousands of static plants — because the two want different things and sharing one of them cost this engine its whole particle look. A blade of grass needs a yaw and a wind response and is opaque; a puff of smoke needs an age, a seed and an opacity, and has no wind of its own because its velocity already carries it.

Lacking those three, the scatter path had to fake the one that matters: a particle "faded" by having its colour multiplied toward black, which is a real fade only if the material is additive. Drawn through the opaque foliage shader it is not a fade at all — it is a grain turning into a black cube — and that, rather than any tuning, is why every effect built on this read as raw.

Properties

NameTypeDescription
positionsFloat32ArrayWorld position, three floats each.
sizesFloat32ArrayMetres from the centre to an edge, a half-width: the quad spans twice this. Then radians of roll about the particle's own axis. This said metres across until 4.8.3, and a caller who took it at its word drew every particle twice as wide as meant.
spinsFloat32Array
colorsFloat32ArrayLinear colour, three floats each.
alphasFloat32ArrayOpacity, 0 to 1 — a real one, not a colour standing in for it.
agesFloat32ArrayAge as a share of this particle's own life, for anything that evolves.
seedsFloat32ArrayPer-particle randomness, so neighbours never animate together.
velocitiesFloat32ArrayCurrent velocity, three floats each: what a streak is stretched along.
framesoptionalFloat32ArrayA sprite's flipbook frame, one float each: its whole part names a cell of the image, counted across then down from the top-left, and its fraction is how far toward the next a batch that blends cells has come. Read by the 'sprite' material alone. Absent is frame 0.
heightsoptionalFloat32ArrayA sprite's half-height in metres, one float each, beside sizes' half-width — a sprite need not be square. Read by the 'sprite' material alone; absent or 0 is as tall as it is wide.
countnumber
capacitynumber