Skip to content

Tutorials · Particle Effects · Chapter 5

Curves and gradients

25 minutes Uses: ParticleEmitter

By the end

  • Forge fire, forge_fire, in the forge’s mouth: white at the coals, then yellow, orange and smoke grey as it rises
  • Forge sparks, forge_sparks, pale and large while they are fast, red and small as they slow
  • How a curve and a gradient are drawn in the Inspector, and what each one multiplies
On this page

Fire over its life

Chapter 2 gave a particle a colour at birth and another at death, and a size at birth and another at death. It runs straight from the one to the other. A flame does not live like that. It is white where it is born, turns yellow, then orange, then goes the grey of smoke, and it swells as it takes hold and shrinks as it burns out. Three controls bend the straight run. Each is a shape you draw across a particle’s life, from its birth at the left to its death at the right.

First the fire itself. It is an emitter like the others, so it goes on a node of its own, at the forge’s mouth.

  1. Select Town, press + Add node and choose Particles. Rename it forge_fire, and set its Position to 114 and 280, the coals in the forge’s mouth.
  2. Set Rate to 40, Lifetime to 0.9, Speed to 28, Spread to 0.5 and Gravity to -30. Direction stays 0, -1, straight up.
  3. Set Start Color to 1, 1, 1, alpha 1, and End Color to 1, 1, 1, alpha 0. If the picker’s button at the top left reads U8, press it so it reads F, as in chapter 2. Both are white so that the gradient below decides the colour, and the alpha still fades to nothing.
  4. Set Start Size to 10, End Size to 6, Capacity to 40, Sort Layer to 3 and Blend to Add. Set Texture to soft-dot.png.
  5. Open Emission Shape, set Shape to Box, and Size to 32 and 4, the width of the coals. Leave Edge Only unticked.

The fire is a white flicker for now. In the Inspector the shapes sit in a group called Over Lifetime, each on a row with a tick box and a small preview. The labels are cut short by the narrow panel, as Size Ove…, Color Ov…, Rotation Ov… and Velocity …: they are Size Over Life, Color Over Life, Rotation Over Life and Velocity Over Life, and chapter 6 takes Rotation Over Life. Ticking a row switches the shape on, and the arrow at the left of its name opens it.

forge_fire selected, its Inspector narrowed with the search box to the rows that mention over life: under Over Lifetime the rows Size Ove…, Color Ov… and Velocity …, each ticked and each with a small preview, a curve that rises and falls, a bar that runs from pale yellow through orange to a see-through end and a curve that slopes down, and Rotation Ov… with its box unticked; under By Speed, Color By Sp… unticked; in the Viewport the node sits in the forge’s mouth with its arrows

A gradient for the colour

  1. Tick Color Over Life and press the arrow at its left. A bar opens, plain white: a gradient with no stops changes nothing. The bar runs from 0, birth, at its left end to 1, death, at its right.
  2. Click the strip just above the bar, at its left end. A square appears: a colour stop, selected. Beside Step are its swatch and its place along the bar, at. Click at, type 0 and press Enter. Then click the swatch and set it to 1, 1, 1, white.
  3. Click the strip about an eighth of the way along, set at to 0.12, and set the swatch to 1, 0.8, 0.25, a yellow. Add a stop a little before the middle, at 0.4, set to 1, 0.4, 0.08, an orange, and one at the right end, at 1, set to 0.35, 0.33, 0.32, the grey of smoke.
  4. Now click the strip just below the bar. These are alpha stops, which are set apart from the colours: a stop here sets how solid the particle is. Beside Step are its alpha and its at. Add three: alpha 1 at 0, 0.9 at 0.7 and 0 at 1.
  5. To move a stop by hand, drag it along the bar. Right-click a stop, or press Delete with it selected, to take it away.
The same rows with Color Ov… opened: a bar that runs from bright yellow through orange to a chequered, see-through end, with small squares above it, the colour stops, the yellow one second from the left selected, and small squares below it, the alpha stops, 0 and 1 under it, and below them a Step button, a yellow swatch and a box reading at 0.12, the selected stop’s colour and place; Size Ove…, Rotation Ov… and Velocity … are closed
Color Over Life
A gradient of colours and alphas across a particle’s life, from birth at 0 to death at 1. It is multiplied with the run from Start Color to End Color, not put in place of it, so with both of those set to white the gradient alone decides the colour. Colour stops take three numbers from 0 to 1; alpha stops take one. Here, four colour stops and three alpha stops, from white through yellow and orange to grey. Left unticked it does nothing: an empty gradient is white.
at
Where the selected stop sits along the bar, from 0 at its left end to 1 at its right: on Color Over Life, the moment in a particle’s life the stop’s colour or alpha is reached. Here the yellow is reached at 0.12 of the life and the orange at 0.4. A stop typed past its neighbour stops there.
Size Over Life
A curve that multiplies a particle’s size across its life: 1 leaves the size as Start Size and End Size run it, 0.5 halves it. Here it climbs from 0.6 at birth to 1 a third of the way up the life, 0.3, then falls to 0.4, so a flame swells as it takes hold and shrinks as it burns out. 0.4 to 1 suits a flame; a curve that reaches 0 makes the particle vanish at that point.
Velocity Over Life
A curve that multiplies how far a particle travels each step, and with it all of its speed, gravity’s share too. Here it falls from 1 at birth to 0.3 at death, so the flames slow as they die and stay near the coals. 0.3 to 1 suits a flame. A curve that reaches 0 stops the particle dead, wherever it is.
x and y
The selected point of a curve. x is where it sits along the canvas, from 0 at the left to 1 at the right: on an Over Life curve, how far through a particle’s life. y is the number the curve reads there, the one that multiplies. Here the size curve’s middle point is at x 0.3 with y 1. A point typed past its neighbour stops at it.

To draw a curve, tick its row and open it. A new curve is two points at 1, a flat line, which changes nothing. Double-click the line to add a point; the new point is selected. Click a point to select it, and two boxes show under the Shape button: x, where the point sits, and y, the number the curve reads there. Click a box, type a number and press Enter, or drag the point itself on the canvas. Right-click a point, or press Delete with it selected, to remove it. The two numbers at the top and the bottom of the canvas are the highest and the lowest value it shows, and they move as the curve does. The Shape button starts the curve over from a preset, or sets how the stretch of curve after the selected point is drawn. On a stretch drawn Cubic, a selected point also shows in and out, the slopes the curve arrives and leaves on; this chapter keeps every stretch straight.

  1. Tick Size Over Life and open it. Double-click the line about a third of the way along to add a point there, and set its x to 0.3. Its y is already 1.
  2. Click the left point and set its y to 0.6. Click the right point and set its y to 0.4.
  3. Tick Velocity Over Life and open it. Click the right point and set its y to 0.3. The left point stays at 1.
  4. Press Ctrl+S, then F5: the fire runs white, yellow, orange and grey. Press F5 again to stop.
The same rows with Size Ove… opened: a canvas holding a curve of three points, one near the bottom left, a peak a little way in from it at the top, selected and drawn white, and one near the bottom right, with 1.0 at the top of the canvas, 0.34 at its bottom, 0 and 1 beneath it, a Shape button, and under it two boxes reading x 0.30 and y 1.00, the peak’s numbers; Color Ov… and Velocity … below it are closed, each with its preview

The pictures below are cut close to the forge’s mouth, drawn in a very large window so that each flame is a handful of pixels wide. The small orange specks above the flames are the forge sparks, which you add next.

Close up of the forge’s mouth: flames that are white at the coals at the bottom, yellow just above them, orange higher, and a dim brown at their tips, with a few small orange specks flying above them
Close up: white at the coals, then yellow, then orange, then a dim brown at the tips.
The same close up with the gradient taken off: the same flames, every one white or pale grey from the coals to the tips, and the same orange specks above them
For comparison, without Color Over Life: the same flames, all white.
The same close up with the size curve taken off: the same flames in their colours, the blobs at their tips larger and softer, as large as those lower down
For comparison, without Size Over Life: the flames keep the plain run from 10 to 6, so their tips stay broad and they do not swell and shrink.
The same close up with the velocity curve taken off: the flames in their colours reaching higher, up into the arch of the forge, in a thinner, more scattered tail
For comparison, without Velocity Over Life: the flames reach higher, because nothing slows them.

Colour and size by speed

A spark is bright and thin while it is fast and dull and round as it slows, and how fast it is has little to do with how old it is: one thrown upward slows to a stop at the top of its flight and then speeds up again on its way down. The same two shapes can be read against speed instead of age. They sit in a group called By Speed.

  1. Select Town, press + Add node and choose Particles. Rename it forge_sparks, and set its Position to 114 and 276.
  2. Set Lifetime to 1.4, Speed to 110, Direction to 0.3 and -1, Spread to 0.9 and Gravity to 180. Gravity is positive, so the sparks arc up and fall back. Rate is already 20, and End Size already 2, as every new Particles node has them.
  3. Set Start Color to 1, 0.9, 0.6, alpha 1, and End Color to 1, 0.4, 0.1, alpha 0.
  4. Set Start Size to 4.5, Capacity to 32, Sort Layer to 4 and Blend to Add. Set Texture to soft-dot.png, and Drag to 0.6.
  5. Tick Size By Speed and open it. Click the left point and set its y to 0.6, then click the right point and set its y to 1.4.
  6. Tick Color By Speed and open it. Add two colour stops: one at 0 set to 1, 0.35, 0.1, a red-orange, and one at 1 set to 1, 1, 0.9, a pale cream. Leave the alpha strip empty: alpha is 1 throughout.
  7. Set Speed Range to 0 and 160. Press Ctrl+S.
forge_sparks selected, its Inspector narrowed with the search box to the rows that mention speed: Speed 110.00, then under By Speed the rows Size By … and Color By…, both ticked and each with a small preview, a curve that rises to the right and a bar from red-orange to pale cream, and Speed Range with x 0.0 and y 160.0; in the Viewport the node sits just above the forge’s floor
Size By Speed
A curve that multiplies a particle’s size by how fast it is going at that moment. Its left end is the slowest speed in Speed Range, its right end the fastest. Here 0.6 at the slow end and 1.4 at the fast end: a fast spark is 1.4 times its size and a slow one 0.6 times. 0.5 to 1.5 suits a spark.
Color By Speed
A gradient that tints a particle by its speed, multiplied in as Color Over Life is. Here a red-orange at the slow end and a pale cream at the fast end, so a fast spark runs pale and a slow one reddens. It takes the same colour and alpha stops as Color Over Life.
Speed Range
The two speeds, in world units a second, that the two by-speed shapes read as 0 and 1: the slowest first, the fastest second. One range serves both shapes. Here 0 and 160: a spark leaving at 110 starts about two thirds of the way along, and reddens as Drag and gravity slow it. A particle slower than the first number reads as 0, and one faster than the second as 1. Set the second a little above the fastest speed the emitter makes.
Close up of the forge’s mouth with its flames and sparks, a little later: the sparks that have flown high above the flames are small and orange, with the flames’ blobs below them in white, yellow and orange
Close up: the sparks that have climbed above the flames are small and orange.
The same close up with the two speed rows taken off: the same flames, and the sparks high above them now pale cream, a little larger than before
For comparison, without the speed curves: the same high sparks are cream, as pale as when they were born, and a little larger.
The same close up with Speed Range 0 and 60: the flames the same, and more of the sparks high above them pale, several of them cream-white
For comparison, Speed Range 0 to 60: any spark faster than 60 now reads as fully fast, so more of them are pale.

What curves cost

The forge fire and the forge sparks

The forge fire

FieldValue
Position114, 280
Rate40
Lifetime0.9
Speed28
Direction0, -1
Spread0.5
Gravity-30
Start Color1, 1, 1, alpha 1
End Color1, 1, 1, alpha 0
Start Size10
End Size6
Capacity40
Sort Layer3
BlendAdd
Texturesoft-dot.png
ShapeBox, Size 32, 4, Edge Only unticked
Color Over Lifecolour stops 0 (1, 1, 1), 0.12 (1, 0.8, 0.25), 0.4 (1, 0.4, 0.08), 1 (0.35, 0.33, 0.32); alpha stops 0 (1), 0.7 (0.9), 1 (0)
Size Over Lifepoints 0 (0.6), 0.3 (1), 1 (0.4)
Velocity Over Lifepoints 0 (1), 1 (0.3)

The forge sparks

FieldValue
Position114, 276
Rate20, as a new node has it
Lifetime1.4
Speed110
Direction0.3, -1
Spread0.9
Gravity180
Start Color1, 0.9, 0.6, alpha 1
End Color1, 0.4, 0.1, alpha 0
Start Size4.5
End Size2, as a new node has it
Capacity32
Sort Layer4
BlendAdd
Texturesoft-dot.png
Drag0.6
Size By Speedpoints 0 (0.6), 1 (1.4)
Color By Speedcolour stops 0 (1, 0.35, 0.1), 1 (1, 1, 0.9); no alpha stops
Speed Range0, 160

Every other field is as a new Particles node has it. Chapter 6 gives both a sheet of pictures to play.

Check it works