Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

particle_data

The per-particle channel, read from a material.

A particle carries four numbers into the material that draws it — life (its normalised age, 0 → 1), seed (its own random in [0, 1], fixed for its whole life), size (the world-space size it is drawn at this frame), and alive. particle_layout declares the four as ParticleData; this module is how a shader reads them back.

#include "@builtin::deprecated.deprecatedParticles.particle_data"

fn fragment(input: FragmentData) -> vec4<f32> {
    let p = particle_sprite_data(input);          // particle_mesh_data for a mesh emitter
    let flicker = 0.6 + 0.4 * sin(input.time * 8.0 + p.seed * 6.2831);
    return vec4<f32>(input.vertex_color.rgb * flicker, input.vertex_color.a * (1.0 - p.life));
}

The two emitter paths carry the channel in different places — a sprite in the four tangent words of each vertex of its billboard quad, a mesh in an instance shader-data lane — so there is one accessor for each, and both hand back the same ParticleData.

seed is what makes a population vary out of unison: it differs between the particles of one emitter and reproduces for the same particle at any age, so a noise phase or an atlas frame chosen from it is that particle's own and holds still while it lives. @builtin::deprecated.deprecatedParticles.fx.fx_noise takes it directly as a phase or an offset.

This is the per-PARTICLE channel. renderer.instanceData is the per-ENTITY one: a sprite emitter is a single entity, so the lanes it sets are shared by every particle the emitter draws.