Skip to content

Water and waterfalls ​

A map's water is its cells of water (the editor's water brushes, Flood, or a river path: MapPath.profile). The client draws it pixel by pixel to the bank, shallows showing the ground through, with waves rolling to the shore, rivers flowing, and waterfalls wherever water spills to a lower level.

Quick start ​

ts
import type { MapEnvironment } from '@v12-engine/engine'
import type { WaterWaves } from '@v12-engine/client'

const waves: WaterWaves = {
	on: true, // false: none
	strength: 0.6, // 0..1: how much the crests and the foam show
	length: 3, // cells from one crest to the next
	speed: 1.2, // cells a second they come in at, and a river runs at
	reach: 10, // cells out from the shore they are seen, up to 24
	foam: [0.93, 0.96, 0.96] // the colour of their foam
}
const environment: MapEnvironment = { water: { shallow: [0.28, 0.55, 0.62], waves } }

That gives the map greener shallows and stronger, shorter waves. Every field is optional; WATER_WAVES holds the defaults.

Common tasks ​

Set the water for every map ​

ts
world: { environment: { water: { deep: [0.05, 0.12, 0.3], waves: { strength: 0.4 } } } } // GameView.world

A map's own environment.water goes over it.

Change the water while playing ​

ts
// this screen only
client.setEnvironment({ water: { ...client.mapEnvironment.water, waves: { strength: 1 } } })
// every player, from the rules, eased over 4 s
world.setEnvironment({ water: { waves: { on: false } } }, { over: 4 })

Add or tune waterfalls ​

ts
import type { MapEnvironment } from '@v12-engine/engine'
import type { MapWaterfall, WaterFalls } from '@v12-engine/client'

const falls: WaterFalls = {
	on: true, // false: none at all, found or placed
	auto: true, // false: only those put down by hand
	width: 0.9, // 0.2..1: how much of the edge the water spills over a found fall covers
	speed: 2.5, // cells a second the water runs down them
	mist: 0.6, // 0..1: how much mist rises at their feet
	color: [0.82, 0.9, 0.94], // the falling water's colour
	foam: [0.95, 0.97, 0.98], // the foam's where they land
	least: 1, // the least step of the water's surface between two cells that falls, where no cliff or ramp is
	sound: 'waterfall', // a sound of the game's, made to loop: none when left out
	volume: 0.6 // how loud a fall a cliff high is; lower ones softer, wider ones heard further
}
// one put down by hand: its lip's middle, the way it falls (as facings turn: 0 toward +z), how wide
const spring: MapWaterfall = { id: 1, name: 'spring', x: 80.5, z: 136, facing: 0, width: 1.5 }
const environment: MapEnvironment = { water: { falls }, waterfalls: [spring] }

Falls are found by themselves over cliffs, down ramps, and where the water's surface steps down by more than least. WATER_FALLS holds the defaults (no sound).

List the waterfalls ​

client.waterfalls.list gives each Waterfall as drawn: its lip's middle, the way it falls, its width, top and foot heights, how far out it lands, and the id of the hand-placed one it is.

Editor ​

  1. Open the Look panel, Water section.
  2. Set Waves (on/off), Strength, Wave length, Speed, Reach and Foam.
  3. Set Waterfalls, Found from the ground, Width, Least drop, Speed, Mist, colours, Sound and Volume.
  4. Press Put waterfalls down to place your own: click to place ([ and ] turn it), drag to move.
  5. Each change is one undo step and shows on the map at once.

Reference ​

WaterLook (MapEnvironment.water) ​

FieldWhatDefault
shallowcolour of the shallowsa pale blue-green
deepcolour of deep watera dark blue
opacityhow much of what is under it shows, 0 (clear) to 10.78
flowripple speed, cells a second0.25
shoredepth until it is fully thick, a soft edge0.4
wavesWaterWavesWATER_WAVES
fallsWaterFallsWATER_FALLS

Order: the map's, then the game's GameView.world.environment.water, then the client's.

How waves behave ​

  • Seas and lakes: crests lie along the shore and roll in, steep in front, breaking in foam that washes up the bank.
  • Rivers: water up to seven cells across, or whose surface falls, flows instead: ripples carried along (a flow map) and foam along the banks. A river flows downhill; on level ground it flows east (or south if it runs north to south).

The waves come from a field of distance to shore and flow direction, worked out when the map shows and again around each change (about 4 ms a brush stroke on a 512 map).

Waterfalls ​

Each fall is a sheet from where the water slopes to the edge, over the lip, down clear of the rock (or along a ramp), into a ring of foam that drifts away, with mist at its foot and an optional looping sound (a MapEmitter, heard as far as it is wide and high). A hand-placed fall drops as far as the ground ahead does, or its drop; on: false turns one off. Hand-placed falls move with the map when it is grown or cut, and mirror with its symmetry. The map's checks flag one off the map, of no width, or with a duplicate id.

Quality and cost ​

At Low effects, waves and their field are not drawn, and waterfall mist is not played; sheets and foam draw at every quality. Waves cost at most a quarter of a millisecond of GPU where they fill the view, and add only a texture and two uniforms to the shader. All falls of a map are two meshes and two materials; finding them is about 6.5 ms on a 512 map, done when a brush stroke rests and only near water.