Log inGet started
Package

Fire.component

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

Fire

Fire with its smoke, as a component: a campfire or a hearth, a torch, a brazier or a candle-sized flame, a bonfire or a pyre, a building, a vehicle or a forest on fire, or an explosion's fireball. Put it on an entity where the fire burns and it burns there: flames that glow white-hot at the core through yellow and orange to dull red at the tips, grey or black smoke rising over them lit by the scene with a shadow of its own, and a point light that lights the ground, the walls and the people around it and the smoke from within.

local e = entity.spawn("campfire")
e.localPosition = { 0, 0, 0 }
e.component.add("Fire", { style = "campfire" })

An explosion is a burst: the explosion style ignites when the component starts, and gameplay sets it off again by changing ignite:

local boom = entity.spawn("barrel_explosion")
boom.localPosition = { 6, 0, 3 }
boom.component.add("Fire", { style = "explosion" })
-- later, to set it off again:
local fire = boom.component.get("Fire")
fire.ignite = fire.ignite + 1

For smoke alone use the Smoke component.

Fires and smoke whose boxes overlap draw as one group, the widest first and the ones it holds over it: small fires breaking out along a burning barn show in front of the barn's big smoke plume.

Styles

styleWhat it isHeightFlamesLight
campfireFlames a metre high under a thin grey smoke5 m1.2 m6, radius 9 m
torchA small flame with a thin wisp of smoke1.6 m0.6 m3, radius 6 m
bonfireRoaring flames a few metres high under heavy smoke12 m3.6 m14, radius 20 m
burningWide flames under thick black smoke: a building or vehicle on fire22 m6.6 m24, radius 30 m
explosionA fireball that swells, rises and cools into dark smoke over 2.6 s9 mthe ball40 while it burns

Public fields

FieldTypeSyncDefaultMeaning
styleenumSync"campfire"The kind of fire (above).
heightnumberSync0Metres the fire and its smoke rise; 0 takes the style's. Its width scales with it.
radiusnumberSync0Metres from the centre to the edge of the flames at their base; the smoke widens from it as it climbs, by the style's spread. 0 takes the style's at this height.
flamenumberSync1How bright the flames burn, as a multiple of the style's.
flameHeightnumberSync0Metres the flames reach above the base; 0 takes the style's (the Flames column, scaled with height). Tall flames for a house fire: flameHeight = 10.
smokenumberSync1How thick the smoke is; 0 burns clean.
colorcolorSyncwhiteTints the style's smoke colour.
lightnumberSync-1The intensity of the point light it casts; -1 takes the style's, 0 casts none.
flickernumberSync1How far the light rises and falls with the flames (0 to 1); 0 holds it steady.
speednumberSync1How fast the flames lick and the smoke climbs.
windX, windZnumberSync0Metres the top of the smoke drifts along world x and z, on top of what the scene's wind carries it.
sceneWindnumberSync1How far the scene's wind carries the smoke: 1 drifts with every Wind blowing at the source (Physics.wind), the top carried by the wind for as long as the smoke takes to climb there (up to half the plume's height; a thin wisp drifts far, a big fire's column stands up to the wind); 0 leans it by windX / windZ alone.
seednumberSync0Which turbulence it takes.
loopbooleanSyncfalseFor explosion: start over once its smoke has cleared.
ignitenumberSync0For explosion: each change sets it off again.
qualityenumNoSync"auto"auto follows the device's quality tier; high, medium, low.
lightResponsestringSync""The .shaderModule its light is drawn with, for a drawn style: toon bands, a palette, an ink line, a hard silhouette, flames in flat bands. Empty draws the engine's own light. @builtin::systems.volumetrics.shaders.medium_light's README states what a response defines.
lightResponseParamstableSync{}Up to sixteen numbers the response reads as params (colours, thresholds), in order.

The light is a point light halfway up the flames, where it lights the ground, the logs and the walls around the fire and the smoke from within. It stands on a child entity the fire puts up for the session and keeps out of every save (fire:lightEntity() answers it), and flickers with the flames (flicker), each peer drawing its own.

A fire is seen the way anything is: a wall, a roof or any opaque surface in front of it hides it. A building on fire shows its flames where it is open, so stand the fire where the roof has burnt through, in a doorway or at a broken wall, or above the roofline.

Drawn in a style

lightResponse names a .shaderModule of the world that draws the flames and the smoke in a style instead of the engine's own light: flat lit and shade tones with a hard edge, a painted palette, an ink line, a crisp silhouette, flames in a few flat bands. The module includes @builtin::systems.volumetrics.shaders.medium_light and defines medium_shape, medium_light and medium_flame; that module's README states what each is handed and shows a two-tone response. One module can draw the clouds (VolumetricSky), smoke, fire, volumes and fog banks (ParticipatingMedium) alike, and the volumetrics guide (systems/volumetrics/documentation/README) walks through it.

Cost

The same as the Smoke component's: a 3D texture written every frame the scene draws and marched over the pixels its box covers, at 48, 40 or 32 voxels across with 96, 64 or 48 march steps for high, medium and low, over the whole view at high and half its width and height at medium and low. A campfire filling a 1920 x 1080 view costs 7 to 14 ms at high and 0.38 ms at medium on a desktop GPU; from 9 m away 0.69 and 0.13 ms.

Related

  • Smoke: smoke without flames.
  • plume module: the same fire from a script (plume.create).