Customising grass and bushes
Every setting of grass and bushes, group by group: what each group is for, a small example you can see, and a table of its fields with their defaults. The look (FoliageLook, given to foliage) is how it is drawn on each screen; the rules (FoliageStyleDef and foliagePack) are what it does in the game. The end of the page has ten looks to copy.
// src/view.ts: in your view's ground.cellLayers
import { foliage } from '@v12-engine/client'
// say only what you change: every field has a default
export const grass = foliage({
height: 0.8, // world units: a unit stands about 1.5, a tree 3.5 to 4.7
density: 5, // tufts a cell
colors: { foot: [0.2, 0.4, 0.12], tip: [0.6, 0.78, 0.3] }
})Done: knee-high green grass, five tufts a cell, on every cell of the layer.
Sizes are in world units, distances and radii in cells (one cell is one world unit), angles in degrees, colours three numbers from 0 to 1 (red, green, blue), and times in seconds.
What is drawn
A style is drawn as grass made in code, or as your own models (bushes). One layer can mix both: each style says its own.
import { foliage } from '@v12-engine/client'
export const field = foliage({
draw: 'grass', // value 1 of the layer: grass
density: 4,
styles: {
// value 2: bushes from the shared art, picked by weight
2: { draw: 'models', models: [{ src: 'forest/bush_common_flowers.glb' }, { src: 'forest/bush_common.glb', weight: 0.3 }], density: 0.7, height: 1.2 },
// value 3: nothing drawn, though the rules may still hide and burn it
3: false
}
})| Field | Default | What it does |
|---|---|---|
draw | models where models names any, else grass | 'grass' or 'models' |
models | Your models: { src, scale, weight } each. src is a path under the game's assets, weight how often it is picked (1) | |
styles[n] | A look for the cells painted with value n, over the layer's; false draws nothing there | |
seed | 0 | The layout's seed: the same seed lays the same field on every screen |
seeThrough | yes | Grass round your own units is drawn see-through, so you see them |
shadow | no | Models cast shadows: true, 'near' (near the camera only) or false. Grass never does |
Models do not take shape, light, scatter, colors.foot, tip, stops, saturation or ground, nor a style's own wind. See Make bushes of my own.
Shape
What one tuft is made of. A tuft is flat blades leaning out from one foot, a blade tapers and curves, a cross is two or three crossed cards with a picture, a mesh is a model of yours used as a tuft.
import { foliage } from '@v12-engine/client'
export const shapes = foliage({
shape: { kind: 'blade', blades: 4, width: 0.05, curve: 0.4, droop: 0.25 }, // long blades that hang over
styles: {
2: { shape: { kind: 'tuft', blades: 8, width: 0.2, spread: 0.15 } }, // broad leaves: a low shrub
3: { shape: { kind: 'cross', cards: 3, texture: 'textures/fern.png' } }, // a picture of yours on three crossed cards
4: { shape: { kind: 'mesh', src: 'plants/clover.glb' } } // a small model of yours as each tuft
}
})shape | Default | What it does |
|---|---|---|
kind | 'tuft' | 'tuft', 'blade', 'cross' or 'mesh' |
blades | 5 | Blades a tuft (tuft, blade) |
width | 0.09 | A blade's width at its foot, for a tuft a unit tall |
taper | 1 | How much a blade narrows: 0 as wide as its foot, 1 a point |
curve | 0.3 | How far a tip leans out from its foot, for a tuft a unit tall |
droop | 0 | How far a blade's tip hangs down past its highest point |
spread | 0 | How far apart the feet of a tuft's blades stand: 0 is one foot |
segments | [3, 2, 1] | Parts along a blade near, further off and far: fewer is lighter |
cards | 2 | Cards of a cross, 2 or 3 |
texture | The picture on a cross, by its path under the game's assets | |
alphaCutoff | 0.5 | How see-through a pixel of the picture is before it is left out |
src | The model a mesh is |
Size
How tall it stands, and how much each tuft or bush differs from the next.
import { foliage } from '@v12-engine/client'
export const sizes = foliage({
height: 1, // world units
sizes: {
each: [0.6, 1.4], // each its own size, from 0.6 to 1.4 of the height
noise: { amount: 0.5, scale: 10 }, // taller in patches about 10 cells across
edge: { cells: 2, to: 0.4 } // shorter over the last 2 cells of a patch, down to 0.4 at its edge
}
})| Field | Default | What it does |
|---|---|---|
height | 0.6 grass (FOLIAGE_HEIGHT); models as made | How tall, in world units. A model is scaled to it where it is given |
sizes.each | [0.8, 1.25] | The smallest and biggest, of the height |
sizes.width | [1, 1] | The narrowest and widest, of each one's width |
sizes.noise | none | Bigger in patches: { amount, scale }, amount 0 to 1, scale cells across |
sizes.edge | none | Smaller towards a patch's edge: over cells cells, down to the part to |
noise | 8 | Cells across the patches of sizes.noise, colors.patches and placing.clump where they say no scale |
Rotation and lean
Which way each is turned, and how it leans.
import { foliage } from '@v12-engine/client'
export const leaning = foliage({
rotation: {
yaw: [0, 360], // each turned its own way
lean: [5, 15], // each leans 5 to 15 degrees...
leanTo: 'wind', // ...downwind, as the map's wind blows when it is laid
faceWind: 0.5, // and half turned to face downwind
upright: true // upright on slopes, not square to them
}
})rotation | Default | What it does |
|---|---|---|
yaw | [0, 360] | Degrees: one way for all, or each its own between two |
lean | 0 grass, 6 models | Degrees, at most or between two |
leanTo | 'random' | 'random', 'wind', or degrees from north |
faceWind | 0 | How far each turns to face downwind, 0 to 1 |
upright | yes | Upright on a slope, or at right angles to the ground |
Colour
Colours go up a blade from its foot to its tip, with more stops between if you want, and each tuft differs a little from the next.
import { foliage } from '@v12-engine/client'
export const coloured = foliage({
colors: {
foot: [0.15, 0.32, 0.08], // dark at the ground
tip: [0.7, 0.8, 0.35], // light at the tips
stops: [{ at: 0.6, color: [0.42, 0.6, 0.2] }], // a green a little over half way up
vary: 0.15, // each lighter or darker than the next
hue: 0.03, // and a little greener or yellower
patches: { amount: 0.4, scale: 12, to: [0.75, 0.65, 0.35] }, // dry patches about 12 cells across
ground: 0.2, // takes a fifth of the ground's colour under it
dry: { to: [0.7, 0.6, 0.35], amount: 0 }, // dried out: 0 now; raise it with the season
tint: [1, 1, 1] // multiplies everything, models too
}
})colors | Default | What it does |
|---|---|---|
foot, tip | greens | The colour at the foot and the tip of a blade (grass) |
stops | More colours up a blade: { at, color }, at 0 the foot to 1 the tip | |
vary | 0.12 grass, 0 models | How much lighter and darker each is, 0 to 1 |
hue | 0 | How much each differs in hue, 0 to 1 |
saturation | 0 | How much each differs in strength of colour (grass) |
patches | none | Patches of another colour: { amount, scale, to } |
ground | 0 | How much of the ground's colour under it it takes (grass) |
dry | none | Every colour turned towards to by amount, 0 to 1 |
tint | white | Multiplies every colour, models too |
See-through colours
Any colour can take a fourth number: how much of it is seen, from 0 (not at all) to 1 (whole). Blades that fade towards their tips, a style half seen, patches that thin the field out.
import { foliage } from '@v12-engine/client'
export const ghostly = foliage({
colors: { foot: [0.2, 0.42, 0.12], tip: [0.55, 0.72, 0.28, 0.2] }, // the tips a fifth seen
styles: { 2: { colors: { tint: [1, 1, 1, 0.5] } } } // the whole of style 2 half seen, its bushes too
})It is drawn as a dither: a stipple. A fixed pattern of the pixels is left out, so nothing is blended or sorted, and the pattern stays put as the camera moves. Up close you can see the dots; it is not smooth glass. A whole colour costs nothing more.
| Colour | Its fourth number |
|---|---|
foot, tip, stops | How much is seen at the foot, the tip and between |
tint | How much of the whole style is seen, grass and models |
patches.to, dry.to | Turned towards as far as the colour is: thin patches, grass that dries to nothing |
ruined.crushed, ruined.burnt | How much of crushed, cut and charred grass is seen |
scatter colours | How much of each kind of flower is seen |
The glow of fire (fire.color) and a light's colour take three numbers only: they are light added.
Placing
Where tufts and bushes stand in the cells of their layer, and where they never grow.
import { foliage } from '@v12-engine/client'
export const placed = foliage({
density: 6, // tufts a cell
placing: {
clump: { amount: 0.6, scale: 6 }, // thicker in clumps about 6 cells across
edge: { cells: 2, to: 0.3 }, // thinner over the last 2 cells of a patch
jitter: 0.9, // scattered: 0 stands in rows, 1 anywhere in the cell
slope: [0, 30], // none on slopes steeper than 30 degrees
notTiles: ['sand', 'rock'], // never on these ground tiles
keepOff: { roads: true } // and off the `road` tile too
}
})By itself, grass keeps off water, the walls of cliffs, the ground under buildings and scenery that blocks the way. It does grow on the road tile, as on any ground painted with the layer: keeping off roads is yours to ask for, with keepOff.roads: true. Models keep off nothing unless their look says keepOff.
| Field | Default | What it does |
|---|---|---|
density | 3 tufts, 0.7 models | A cell. A part of one is a chance of one. Fewer at the player's lower Tall grass setting |
placing.clump | none | Thicker in patches: { amount, scale } |
placing.edge | none | Thinner towards a patch's edge: { cells, to } |
placing.jitter | 0.8 grass, 0.7 models | 0 in rows to 1 anywhere in the cell |
placing.slope | every slope | [least, steepest], degrees |
placing.tiles | every tile | The tile ids it grows on alone |
placing.notTiles | The tile ids it never grows on | |
placing.keepOff.water, cliffs, buildings, doodads | yes for grass, no for models | false grows through it (reeds in water: keepOff: { water: false }) |
placing.keepOff.roads | no | true keeps it off the road tile |
What the screen keeps off is the screen's alone. To the rules the cells are where they were painted: grass kept off a road on the screen is still there to them, so paint it away (clearFoliage, or the editor's brush) where it should not be. Grass on the road tile, on water, under a building or on cells that block the way never burns, whatever the look says.
Wind
How a style moves in the map's wind (MapEnvironment.wind) and in gusts.
import { foliage } from '@v12-engine/client'
export const windy = foliage({
wind: { sway: 1.2, stiffness: 0.2, waves: 1.5, sheen: 0.5 }, // a soft meadow: big waves, shining as it bends
styles: { 2: { wind: { stiffness: 0.85, waves: 0.2, flutter: 0.6 } } } // reeds: stiff, tips shivering
})wind | Default | What it does |
|---|---|---|
sway | 1 | How much it sways, 0 for none |
stiffness | 0.4 | 0 soft to 1 stiff |
waves | 1 | How much it joins the waves that roll downwind over a field |
flutter | 0.3 | Tips shivering in a strong wind |
lean | 1 | Leaning downwind as the wind gets up |
speed | 1 | How fast it sways |
sheen | 0.3 | Lighter tips as blades lie over: what shows the wind from above |
The map's wind is { around, strength, gusts }: degrees it blows towards from north, 0 (still) to 1 (a gale), and how much it comes and goes. Set it in the editor's Look panel or with world.setEnvironment({ wind }). Bushes follow the layer's wind, not a style's. See Make grass follow the wind.
Walked on
How grass and bushes move as units go through them, and whether grass lies down and leaves a trail. It is each screen's alone.
import { foliage } from '@v12-engine/client'
export const trodden = foliage({
walked: { bend: 1.2, radius: 'size', flatten: 0.7, recover: 10, who: 'all' },
styles: {
2: { walked: { flatten: 0.9, recover: 0 } }, // wheat stays down until it grows again
3: { walked: { flatten: 0.3, trail: false } } // reeds spring back at once
}
})walked | Default | What it does |
|---|---|---|
bend | 1 | How far it bends away from who is in it |
radius | 1.6 | Cells round them, or 'size': by each unit's size, at most 3.2 |
wobble | 1 | How far it swings back as it settles |
settle | 1.2 | Seconds the wobble takes |
entry | 2 | How much harder it moves as one steps in |
who | 'all' | 'all', 'friends' (yours and allies'), 'none', or a function: the layer's alone, a style's is not read |
flatten | 0 | How far it lies down underfoot, 0 to 1 (grass) |
recover | 8 | Seconds to stand again; 0 for never, until it grows back |
trail | yes | One moving through leaves laid grass behind |
walked: false turns it off. A hidden enemy is not sent to your screen, so it moves no grass there. For grass the rules crush, see trample below.
Light
How grass is lit. Bushes are lit as models.
import { foliage } from '@v12-engine/client'
export const glowing = foliage({
light: { translucency: 0.5, specular: 0.2, footFade: 0.25, shadows: true }
})light | Default | What it does |
|---|---|---|
shadows | no | Shadows fall on it |
normals | 'up' | 'up' (soft and even) or 'true' (by the way each blade faces) |
translucency | 0 | Light through the tips from behind, 0 to 1 |
specular | 0 | How much it shines |
footFade | 0 | How far up from the foot it fades into the ground, of its height |
Grass never casts shadows.
Distance levels
Further from the camera, fewer tufts are drawn and each is lighter, so a big field stays cheap. Bushes switch to their lighter model files.
import { foliage } from '@v12-engine/client'
export const far = foliage({
levels: { mid: 40, far: 80, cull: 140, midKeeps: 0.6, farKeeps: 0.2, fade: 6 }
})levels | Default | What it does |
|---|---|---|
mid | From this many cells away, fewer are drawn (models: their .lod1 file) | |
far | From this far, the fewest (models: their .lod2 file) | |
cull | never | None past this |
midKeeps | fewer and fewer | The part kept from mid to far, 0 to 1 |
farKeeps | 0.25 | The part kept from far |
fade | 4 | Cells one level fades into the next over |
The player's Detail setting brings every level nearer: half as far on Near, three quarters on Medium. Bushes with no levels use the game's levels for that model.
Ruined
How cut, crushed and burnt grass looks. What makes it so is the rules': ruin, trampling, fire.
import { foliage } from '@v12-engine/client'
export const ruined = foliage({
ruined: {
stubble: 0.1, // cut grass stands at a tenth of its height (a bush's stump the same)
crushed: [0.55, 0.5, 0.3], // the colour crushed and cut grass turns to
burnt: [0.08, 0.07, 0.06, 0.6], // charred, a little see-through
paint: { cut: 'mown', burnt: 'ash' } // painted on the ground under it, or false
}
})ruined | Default | What it does |
|---|---|---|
stubble | 0.15 | Cut height, of its height |
crushed | a dry brown | The colour of crushed and cut grass |
burnt | near black | The colour of what is burnt |
paint | { burnt: 'ash' } | Ground paint under cut and burnt: 'ash', 'mown', a picture's path, or false |
Fire
How burning grass looks and sounds: blades char from the tip down with a glowing edge, with flames, smoke, embers, a few lights and a crackle along the front. Each part can change or be turned off; fire: false turns it all off.
import { foliage } from '@v12-engine/client'
export const burning = foliage({
fire: { color: [1, 0.5, 0.15], scorch: 0.8, embers: false }, // the layer's glow and ash; no embers
styles: {
2: { fire: { bright: 1.3, smoky: 0.5 } }, // dry grass: big, bright, little smoke
3: { fire: { bright: 0.7, smoky: 2, sound: false } } // a thicket: low flames, thick smoke, quiet
}
})fire | Default | What it does |
|---|---|---|
flames | low flames over the ground | An effect by name (burning-ground, one of your view's), or false |
smoke | smoke | An effect by name, or false |
embers | embers | An effect by name, or false |
light | yes | Whether the front lights what is round it: true, false or { color, range, intensity } |
color | orange | The flames and glowing edge, three numbers. The layer's alone |
bright | 1 | How big and bright it burns |
smoky | 1 | How much smoke, 0 for none |
scorch | 1 | How dark the ash left under it is, 0 to 1, or false. The layer's alone |
sound, catches | a crackle, a whoosh | Sounds by name, or false |
How many flames, smoke and embers play follows the player's Effects setting, and the lights show only at the Lights setting's All.
Sound and leaves
import { foliage } from '@v12-engine/client'
export const rustling = foliage({
sound: 'rustle', // the client's own rustle as one moves through it; none when left out
volume: 0.5, // 1 the loudest
leaves: 'leaves' // the ready-made effect of leaves flying, where one steps in
})| Field | Default | What it does |
|---|---|---|
sound | none | A sound by name ('rustle' is the client's own), or false |
volume | 0.7 | How loud, 1 the loudest |
leaves | none | An effect by name played where one steps in, now and then as one moves |
Flowers and small plants
scatter mixes a few plants into a style of grass. They are laid with the grass, sway, burn and are cut with it.
import { foliage } from '@v12-engine/client'
export const flowery = foliage({
scatter: [
{ density: 0.15, height: 0.35, colors: [[0.95, 0.88, 0.35], [0.85, 0.4, 0.62]] }, // yellow and pink heads on short tufts
{ density: 0.05, src: 'plants/fern.glb', sizes: [0.7, 1.3] } // a model of yours, now and then
]
})A scatter entry | Default | What it does |
|---|---|---|
density | How many a cell: 0.1 is one in ten cells | |
height | half the grass's | World units |
colors | white | The colours of their tips, one picked for each; a fourth number is how much is seen |
sizes | [0.8, 1.2] | Each its own size, of the height |
shape | a short tuft of three wide blades | Any shape |
src | A model as their shape |
Grass only: models do not scatter.
Grass from ground tiles
on grows grass on every cell painted with some ground tiles, kept in step as the ground is painted.
import { FOLIAGE_TILE_STYLE, foliage } from '@v12-engine/client'
export const lawns = foliage({
on: { tiles: ['grass', 'darkGrass'], density: 2, height: 0.4 },
// grass from tiles is drawn as style 255 where `on.style` says none: give it a look of its own
styles: { [FOLIAGE_TILE_STYLE]: { colors: { tip: [0.5, 0.68, 0.3] } } }
})on | Default | What it does |
|---|---|---|
tiles | The tile ids it grows on | |
style | 255 (FOLIAGE_TILE_STYLE) | The style it is drawn as |
density | 1 | Tufts a cell, where style is left out |
height | 0.7 of the layer's | Where style is left out |
It is the screen's alone: it hides nobody and never burns, until growOnTiles paints it into the layer for the rules. A cell painted with the layer wins over its tile. See Grow grass on ground tiles.
Presets
presetFoliage (looks) and presetFoliageStyles (rules) share their names. Take one whole, or spread it and change what you want.
import { defineCellLayer, presetFoliageStyles } from '@v12-engine/engine'
import { foliage, presetFoliage } from '@v12-engine/client'
export const grassLayer = defineCellLayer({
id: 'grass',
name: 'Grass',
values: [
{ value: 1, name: 'Meadow', foliage: presetFoliageStyles.meadow },
{ value: 2, name: 'Wheat', foliage: { ...presetFoliageStyles.wheat, trample: 'none' } } // wheat nobody crushes
]
})
export const grass = foliage({ ...presetFoliage.meadow, styles: { 2: { ...presetFoliage.wheat, height: 1.3 } } })| Name | Height | Looks | To the rules |
|---|---|---|---|
meadow | 0.5 | short blades, a few flowers | burns, grows back after 90 s |
tallGrass | 1.4 | tall, drooping | hides (1.4 tall), burns, grows back after 120 s |
dryGrass | 0.6 | short, straw-coloured | burns fast and hot, grows back after 150 s |
reeds | 1.8 | stiff, brown heads; grows in water | hides, slows to 0.85, burns a little |
wheat | 1.1 | dense, gold, leans downwind | hides units up to 1.1 tall, burns, crushed underfoot |
snowGrass | 0.4 | short, pale patches | hardly burns, grows back after 180 s |
thicket | 1.4 | wide dark tufts, red berries | hides, slows to 0.6, burns long |
hedge | 1.5 | dense, stiff | hides, nothing walks through it |
All are grass made in code: none needs a model or a picture.
Styles: a look for each patch
Each value painted on the layer is a style. Its look goes in styles under the same number, laid over the layer's look field by field: a group such as colors is laid field by field too, so a style that says only colors.tip keeps the layer's foot.
import { foliage } from '@v12-engine/client'
export const patches = foliage({
height: 0.8,
colors: { foot: [0.18, 0.38, 0.1], tip: [0.55, 0.75, 0.3] },
styles: {
2: { height: 1.4, colors: { tip: [0.7, 0.72, 0.35] } }, // taller and yellower; the same foot
3: { colors: { tint: [0.6, 0.6, 0.6] } } // the layer's grass, darker
}
})A value with no look of its own is drawn as the layer. A layer has up to 255 styles.
How looks are laid over each other
| Order | Where it is | Who writes it |
|---|---|---|
| 1 | foliage(look) in your view | your code |
| 2 | the game's cellLayers.json | the editor, Set for › Every map (the game's) |
| 3 | the map's MapEnvironment.bushes | the editor, Set for › This map; and the rules, world.setEnvironment({ bushes }) |
| 4 | client.foliage(layer).setLook and setStyle | your code, on one screen |
Each lies over the one before, field by field (layFoliageLook). false at any step draws nothing, and what is laid over a false starts from nothing. For the editor's file to play, the view lays it over the code: layFiles(view, [[CELL_LAYERS_FILE, file]]). Change a look in play from the rules for every player:
import type { World } from '@v12-engine/engine'
export function autumn(world: World): void {
const bushes = world.map.environment?.bushes ?? {}
const grass = bushes.grass || {}
// the map's whole `bushes` is replaced: keep what was there, change the part you mean to
world.setEnvironment({ bushes: { ...bushes, grass: { ...grass, styles: { ...grass.styles, 1: { colors: { tip: [0.85, 0.65, 0.3] } } } } } }, { over: 20 })
}The rules of a style
What a style is to the game: whether it hides, slows, burns, grows back and is crushed. It goes on the layer's value, beside its name.
import { defineCellLayer } from '@v12-engine/engine'
export const grassLayer = defineCellLayer({
id: 'grass',
name: 'Grass',
values: [
{ value: 1, name: 'Meadow', foliage: { flammable: 0.6, burns: 6, regrows: 90 } },
{ value: 2, name: 'Tall grass', color: [0.6, 0.7, 0.3], foliage: { conceals: true, height: 1.4, flammable: 1, regrows: 120 } },
{ value: 3, name: 'Bramble', foliage: { conceals: true, speed: 0.6, flammable: 0.4, burns: 12, fuel: 1.5 } },
{ value: 4, name: 'Hedge', foliage: { conceals: true, walkable: false } }
]
})FoliageStyleDef | Default | What it does |
|---|---|---|
conceals | no | Hides who stands in it from teams with nobody in the same patch and nobody within reach |
concealsTaller | yes | With false, a unit taller than height is seen over it |
height | 1 | How tall it stands to the rules, in cells (a unit stands twice its radius) |
speed | 1 | Multiplies the speed of who walks through it; the ways go round slow ground where that is quicker |
walkable | yes | With false, nothing on foot goes through, whatever its state |
flammable | 0 | How easily it catches, 0 (never) to 1 |
burns | 6 | Seconds a cell burns |
fuel | 1 | How hot it burns: how much likelier it lights its neighbours |
regrows | never | Seconds after it was burnt, cut or crushed that it starts to grow back; false for never |
grows | 10 | Seconds it takes to grow back once it starts |
trample | 'none' | 'crush': laid flat for good under who walks over it |
A style's rules are laid the same way as its look: the pack's style for the layer, then the code's value, then the game's data.json, then the map's definitions (the editor's Gameplay, Set for). foliageStyle(game, layer, value) reads the result.
The pack's options
import { foliagePack } from '@v12-engine/engine'
export const grassPack = foliagePack({
layer: 'grass',
style: { flammable: 0.5 }, // every style of the layer, where it says nothing of its own
conceal: { reach: 2, rustle: true }, // how hiding works
tramples: (_world, unit) => unit.def.radius >= 1, // who crushes styles with trample: 'crush'
fire: { damage: 8, wind: 1.5, jump: 0.7, maxBurning: 3000 },
also: [{ layer: 'bush', conceal: { reach: 1 } }] // more layers of the same pack: fire passes between them
})foliagePack | Default | What it does |
|---|---|---|
layer | The layer of cells | |
style | What every style of the layer is where it says nothing | |
conceal | reach (2 cells), hides (units on the ground), seenBy, rustle (no), rustleEvery (0.3 s), heightOf (twice the radius) | |
tramples | every unit that walks | Who crushes a style with trample: 'crush' (never buildings, flyers or ships) |
also | More layers, each with layer, style, conceal, tramples | |
fire | on | FoliageFire, or false for grass that never burns |
FoliageFire | Default | What it does |
|---|---|---|
spread | yes | Whether a burning cell lights those beside it |
every | 0.25 | Seconds between a burning cell's tries |
wind | 1 | How much the wind decides the way: in a gale a try downwind is about 7 times likelier, upwind a seventh |
slope | 1 | How much faster uphill: about 2.7 times on a 45° slope |
jump | never | From this wind strength (0 to 1), it jumps a gap of one cell downwind |
wet | 0 | How wet everything is, 0 to 1 (nothing catches) |
weather | yes | Rain and snow damp it and put it out |
maxBurning | 4000 | The most cells burning at once, over all the pack's layers |
lasts | never | Seconds after which a fire dies |
damage | none | Damage a second to units in a burning cell, dealt by whoever lit it |
damageType | magic | The damage's type |
lights | no | Burning grass sets alight what burns on or beside it, with burningPack: see Let trees burn |
Ten looks to copy
Each is a whole look for ground.cellLayers in your view; where it needs rules of its own, they are beside it.
A lawn
import { foliage } from '@v12-engine/client'
// short, even, bright: a park or a castle garden
export const lawn = foliage({
height: 0.25,
density: 8, // thick
shape: { kind: 'blade', blades: 6, width: 0.05, curve: 0.15 },
sizes: { each: [0.9, 1.1] }, // all nearly the same height: freshly mown
colors: { foot: [0.12, 0.35, 0.08], tip: [0.35, 0.7, 0.2], vary: 0.06 },
placing: { jitter: 1, keepOff: { roads: true } },
wind: { sway: 0.4, stiffness: 0.7, waves: 0.3 }, // short grass hardly moves
ruined: { stubble: 0.3, paint: { cut: 'mown' } }
})A wild meadow with flowers
import { foliage } from '@v12-engine/client'
export const wildMeadow = foliage({
height: 0.7,
density: 5,
shape: { kind: 'blade', blades: 5, curve: 0.35, droop: 0.1 },
sizes: { each: [0.6, 1.3], noise: { amount: 0.4 } }, // uneven: taller in patches
colors: { foot: [0.18, 0.38, 0.1], tip: [0.6, 0.76, 0.3], vary: 0.18, hue: 0.04, patches: { amount: 0.3, to: [0.7, 0.68, 0.35] } },
placing: { clump: { amount: 0.4 }, edge: { cells: 2, to: 0.4 } },
wind: { stiffness: 0.25, waves: 1.3, sheen: 0.4 },
scatter: [
{ density: 0.2, height: 0.45, colors: [[0.95, 0.88, 0.3], [0.95, 0.95, 0.98], [0.8, 0.35, 0.6], [0.45, 0.5, 0.95]] }
]
})Waist-high wheat that leans with the wind
import { presetFoliageStyles } from '@v12-engine/engine'
import { foliage } from '@v12-engine/client'
// the rules: hides units up to 1.1 tall, crushed under feet, burns
export const wheatRules = presetFoliageStyles.wheat
export const wheat = foliage({
height: 1.1,
density: 8,
shape: { kind: 'blade', blades: 4, width: 0.04, curve: 0.12 },
sizes: { each: [0.92, 1.08] }, // a crop: all one height
rotation: { lean: 6, leanTo: 'wind', faceWind: 0.3 }, // laid leaning downwind
colors: { foot: [0.5, 0.46, 0.2], tip: [0.95, 0.82, 0.42], stops: [{ at: 0.8, color: [0.88, 0.72, 0.34] }], vary: 0.06 },
placing: { jitter: 0.4 }, // nearly in rows, as sown
wind: { stiffness: 0.4, waves: 1.8, sheen: 0.7 }, // big golden waves
walked: { flatten: 0.8, recover: 0 } // a path through it stays until it grows again
})Reeds at a shore
import { foliage } from '@v12-engine/client'
export const reeds = foliage({
height: 1.8,
density: 4,
shape: { kind: 'blade', blades: 3, width: 0.05, taper: 0.8, curve: 0.08 },
colors: { foot: [0.24, 0.32, 0.14], tip: [0.62, 0.6, 0.36], stops: [{ at: 0.7, color: [0.44, 0.52, 0.24] }] },
placing: { clump: { amount: 0.5, scale: 4 }, keepOff: { water: false } }, // they grow in the water
wind: { stiffness: 0.8, waves: 0.4, flutter: 0.5 },
walked: { flatten: 0.3, trail: false }, // they spring back
// brown heads standing a little over the reeds
scatter: [{ density: 0.3, height: 2, shape: { kind: 'blade', blades: 1, width: 0.12, taper: 0.2, curve: 0.05 }, colors: [[0.36, 0.24, 0.14]] }]
})Dry savanna
import { foliage } from '@v12-engine/client'
export const savanna = foliage({
height: 0.9,
density: 3,
shape: { kind: 'tuft', blades: 7, width: 0.06, curve: 0.45, spread: 0.05 },
sizes: { each: [0.5, 1.4], noise: { amount: 0.5, scale: 14 } },
colors: { foot: [0.45, 0.38, 0.2], tip: [0.88, 0.78, 0.5], vary: 0.2, ground: 0.25, patches: { amount: 0.4, scale: 16, to: [0.6, 0.48, 0.28] } },
placing: { clump: { amount: 0.7, scale: 5 }, notTiles: ['rock'] }, // tussocks with bare ground between
wind: { stiffness: 0.5, waves: 0.8, sheen: 0.5 },
fire: { bright: 1.3, smoky: 0.6 } // it goes up fast
})Snowy tundra tufts
import { foliage } from '@v12-engine/client'
export const tundra = foliage({
height: 0.3,
density: 2,
shape: { kind: 'tuft', blades: 6, width: 0.07, curve: 0.25 },
sizes: { each: [0.5, 1.2] },
colors: {
foot: [0.36, 0.38, 0.3],
tip: [0.7, 0.72, 0.62],
ground: 0.4, // takes much of the snow's colour under it
patches: { amount: 0.5, scale: 6, to: [0.9, 0.92, 0.95] } // frosted patches
},
placing: { clump: { amount: 0.8, scale: 4 } }, // sparse clumps
wind: { sway: 0.6, stiffness: 0.7, flutter: 0.5 }
})A dark swamp
import { foliage } from '@v12-engine/client'
export const swamp = foliage({
height: 1.2,
density: 4,
shape: { kind: 'blade', blades: 4, width: 0.07, curve: 0.5, droop: 0.4 }, // limp, hanging blades
colors: { foot: [0.06, 0.1, 0.05], tip: [0.25, 0.3, 0.12], vary: 0.1, ground: 0.3, tint: [0.85, 0.9, 0.8] },
placing: { clump: { amount: 0.6 }, keepOff: { water: false } },
light: { footFade: 0.4 }, // rises out of murk
wind: { sway: 0.3, stiffness: 0.6, waves: 0.2 } // still air
})An alien purple field with see-through tips
import { foliage } from '@v12-engine/client'
export const alien = foliage({
height: 1,
density: 5,
shape: { kind: 'blade', blades: 3, width: 0.08, taper: 0.5, curve: 0.6, droop: 0.3 },
colors: {
foot: [0.15, 0.04, 0.25],
stops: [{ at: 0.5, color: [0.55, 0.15, 0.75] }],
tip: [0.4, 0.95, 0.9, 0.25], // cyan tips a quarter seen: drawn as a stipple, not glass
hue: 0.08,
vary: 0.2
},
light: { translucency: 0.8, specular: 0.4 }, // glows against the light
wind: { speed: 0.5, waves: 1.5, sheen: 0.6 }, // slow, heavy waves
scatter: [{ density: 0.1, height: 0.6, colors: [[1, 0.5, 0.2]] }],
fire: { color: [0.4, 0.6, 1] } // blue fire
})A hedge maze wall
import { defineCellLayer } from '@v12-engine/engine'
import { foliage } from '@v12-engine/client'
// the rules: nothing walks through, it hides, it hardly burns
export const maze = defineCellLayer({ id: 'hedge', name: 'Hedge', values: [{ value: 1, name: 'Hedge', foliage: { conceals: true, walkable: false, flammable: 0.2 } }] })
export const hedge = foliage({
height: 2,
density: 10, // a wall: very thick
shape: { kind: 'blade', blades: 10, width: 0.16, taper: 0.6, curve: 0.3, droop: 0.3, spread: 0.2 },
sizes: { each: [0.95, 1.05], width: [1.3, 1.6] }, // clipped: all one height
rotation: { lean: 2 },
colors: { foot: [0.08, 0.2, 0.06], tip: [0.22, 0.4, 0.14], vary: 0.08 },
placing: { jitter: 0.3, edge: { cells: 1, to: 0.9 } },
wind: { sway: 0.2, stiffness: 0.95, waves: 0 },
walked: false, // nothing goes in
seeThrough: false
})A berry thicket of bush models
import { defineCellLayer } from '@v12-engine/engine'
import { foliage } from '@v12-engine/client'
// the rules: hides, slows to 0.6, burns long and hot
export const thicketLayer = defineCellLayer({
id: 'bush',
name: 'Bushes',
values: [{ value: 1, name: 'Berry thicket', foliage: { conceals: true, speed: 0.6, flammable: 0.4, burns: 12, fuel: 1.5, regrows: 240 } }]
})
export const thicket = foliage({
models: [{ src: 'forest/bush_common_flowers.glb' }, { src: 'forest/bush_common.glb', weight: 0.5 }],
density: 1.2, // models a cell: more than one, so they touch
height: 1.3,
sizes: { each: [0.8, 1.3] },
rotation: { lean: 8 },
colors: { tint: [0.85, 0.95, 0.8], vary: 0.1, patches: { amount: 0.3, to: [0.9, 0.7, 0.6] } }, // reddish where the berries are
walked: { bend: 1.2, radius: 1.8 },
leaves: 'leaves', // leaves fly as one pushes in
shadow: 'near'
})