Particles: the look
Unity’s other modules, by the same names:
/// A fire: [flames] a texture of 4 × 4 frames of a flame.ParticleSystem fire(Texture2D flames) => ParticleSystem( startSize: const Range(0.8, 1.2), startLifetime: const Range(0.7, 1), emission: const Emission(rateOverTime: 40), forceOverLifetime: const ParticleVector(y: ParticleCurve(2)), noise: const ParticleNoise(strength: ParticleCurve(0.4), frequency: 1.5, scrollSpeed: 1), textureSheet: TextureSheet(columns: 4, rows: 4), softness: 0.3, material: Material(baseColorTexture: flames, blending: Blending.additive),);In detail
Section titled “In detail”- Curves. A module’s numbers are
ParticleCurves, Unity’sMinMaxCurve:ParticleCurve(2)a constant,ParticleCurve.between(1, 3)random between two constants,ParticleCurve.curve((t) => …, scale:)a curve over each particle’s life,ParticleCurve.curves(a, b)random between two curves. Each particle keeps its own place between the two for its whole life. - Movement.
velocityOverLifetime(aParticleVector, x, y and z curves, in local or world space) is added to how it moves;forceOverLifetimespeeds it up;limitVelocity(aLimitVelocity, noParticlein its name) holds its speed to alimit(bydampen, 0 to 1, a second) and slows it bydrag;rotationOverLifetimeturns it, radians a second;noisepushes it about in a field that moves withscrollSpeed(octavesup to 4, each costing about as much again). - By speed.
sizeBySpeedandcolorBySpeedscale its size and colour fromminSpeedtomaxSpeed: sparks white when fast, red as they slow,colorBySpeed: ColorBySpeed(ColorGradient([...]), maxSpeed: 6)(the curve or the gradient comes first, without a name). - Texture sheets.
textureSheetsplits the base colour texture intocolumns × rowsframes, played over each life (frameOverTime,cycles), from astartFrame, or one row each (randomRow): flames, explosions. - How they’re drawn.
renderMode:ParticleRenderMode.billboardfacing the camera (the default);.stretched(lengthScale:, speedScale:)long the way they move (sparks, rain);ParticleRenderMode.horizontallying flat (ripples, splashes);ParticleRenderMode.verticalstanding up and turning to the camera round up;.mesh(mesh)a mesh each, turned round up by its rotation (leaves, rocks). A mesh in use can’t be disposed. - Soft particles.
softness, in metres: they fade out as they come that close to what’s behind, so smoke doesn’t cut a hard line where it meets the floor. AtQuality.low, which has no depth to read, they’re hard. - Lit particles.
lit: truelights them as a surface facing the camera: smoke the sun falls on. Each square (or a trail’s point) is lit once, at its middle, by the ambient light, the sky, the suns with their shadows and the lamps in reach, as a matte surface, so it’s the same colour across and has no highlights; a cloud of overlapping ones costs little more than unlit ones. Mesh particles are lit pixel by pixel, with the material’smetallicandroughness. - A material’s own shader (A first shader) shades them,
its
unlitorsurfacefunction, withparticle_age()(0 to 1 through its life) andparticle_random()(its own number) to tell them apart.