Skip to main content

Module particles

Module particles 

Source
Expand description

Backend-agnostic resolution of ParticleEmitter components into the ParticleEmitterRecords the backends consume. Each record carries the clamped emitter tunables, the resolved texture pool slot, and the per-frame uniform builder the GPU compute + render passes share. Pure CPU; the per-emitter GPU buffers themselves are allocated by the backend at init.

Structs§

ParticleEmitterRecord
Resolved per-emitter state threaded into the backend at init. The backend allocates one GPU particle pool of max_particles slots per record and drives its compute + render passes from these fields each frame.
ParticleSpawnState
Per-emitter spawn accumulator. The runtime keeps one of these per record and feeds the integer overflow into the compute kernel as spawn_budget each frame. Fractional carry-over keeps low spawn rates honest even when the frame-time is below the per-particle interval.

Constants§

MAX_PARTICLES_PER_EMITTER
Upper bound on the per-emitter pool the backend will allocate. Each slot is 32 bytes on the GPU (matching Particle in shaders/particle_types.slang), so 65 536 slots = 2 MiB per emitter, already well past the visual point of diminishing returns for a billboard pool.

Functions§

build_particle_records
Resolve a list of ParticleEmitter components into ParticleEmitterRecords the backend can consume. Skips invisible emitters and emitters whose pool would be empty. An emitter’s texture carries its cook-assigned TextureHandle, whose value is the texture’s albedo pool slot; texture_count is the pool size and bounds the handle. An out-of-range handle is logged and dropped; an emitter with no texture falls back to slot 0 (white).