Motion SDK

Water and Floods

Rolling waves and a real planar reflection for seas, lakes and wet roads, plus simulated flood water that flows and floats things.

Add water to the material of a flat plane. It ripples and mirrors the scene above it.

A calm sea reflecting a sunset sky and a lit tower.
{
  "camera": { "position": [0, 3, 12], "target": [0, 1.5, -10], "fov": 50 },
  "lighting": { "rig": "moonlight" },
  "environment": {
    "background": {
      "sky": {
        "zenith": "#0a1030",
        "horizon": "#c86a4a",
        "sun": { "elevation": 3, "azimuth": 0 },
        "clouds": null
      }
    }
  },
  "post": { "bloom": 0.8, "tone_mapping": "agx" },
  "materials": {
    "sea": {
      "color": "#0b1a2a",
      "roughness": 0.25,
      "water": { "waves": 0.25, "scale": 4, "speed": 1, "reflect": 1 }
    },
    "beacon": { "preset": "neon", "color": "#ff5a36", "emissive_intensity": 6 },
    "stone": { "preset": "rock" }
  },
  "nodes": {
    "sea": {
      "mesh": {
        "geometry": { "plane": { "size": [200, 200] } },
        "material": "sea"
      },
      "transform": { "rotation": [-90, 0, 0] }
    },
    "tower": {
      "transform": { "position": [2, 1.6, -4] },
      "mesh": {
        "geometry": { "cylinder": { "radius": 0.4, "height": 3.2 } },
        "material": "stone"
      }
    },
    "lamp": {
      "transform": { "position": [2, 3.4, -4] },
      "mesh": {
        "geometry": { "sphere": { "radius": 0.3 } },
        "material": "beacon"
      }
    }
  },
  "timeline": { "duration": 4, "loop": "loop" }
}
A calm sea reflecting a sunset sky and a lit tower. apps/docs/examples/water.json · render it with motion-sdk render apps/docs/examples/water.json -t 1 -o water.png

Settings

  • waves: ripple strength. 0 is a still mirror, for wet tarmac or a calm pond.
  • scale: the wavelength of the biggest waves, in world units. Large for open sea.
  • speed: how fast the waves roll.
  • reflect: how much it mirrors, 0 to 1.

Give the material a dark color and roughness 0.2 to 0.4. Where nothing is mirrored, the water shows the horizon or fog colour.

Limits

  • One water level per scene: the first water plane's height.
  • Reflections cost a second, half-resolution render pass. Use them where they matter.

Flood Water

water on a material is a surface. flood on a node is simulated water that moves. It pours in from sources, spills from fill blocks like a breaking dam, or starts still at level. It runs downhill over terrain, piles up against static bodies, and floats dynamic ones.

A dam breaks. Water floods round a static block and carries a floating crate.
{
  "camera": { "position": [0, 9, 16], "target": [0, 0, 0], "fov": 40 },
  "lighting": { "rig": "golden_hour" },
  "environment": { "background": { "sky": {} } },
  "physics": { "ground": 0 },
  "materials": {
    "flood": {
      "color": "#2a4a52",
      "roughness": 0.3,
      "water": { "waves": 0.2, "scale": 2 }
    },
    "ground": { "preset": "matte_clay", "color": "#8a7a66" },
    "crate": { "preset": "matte_clay", "color": "#c8873a" }
  },
  "nodes": {
    "ground": {
      "mesh": {
        "geometry": { "plane": { "size": [60, 60] } },
        "material": "ground"
      },
      "transform": { "rotation": [-90, 0, 0] }
    },
    "block": {
      "transform": { "position": [3, 1, -1] },
      "mesh": {
        "geometry": { "box": { "size": [2, 2, 2] } },
        "material": "preset:stucco"
      },
      "body": { "type": "static" }
    },
    "crate": {
      "transform": { "position": [-6, 0.4, 1] },
      "mesh": {
        "geometry": { "box": { "size": [0.8, 0.8, 0.8] } },
        "material": "crate"
      },
      "body": { "buoyancy": 1.5 }
    },
    "water": {
      "flood": {
        "size": [24, 10],
        "cells": 64,
        "material": "flood",
        "fill": [{ "from": [-12, -5], "to": [-6, 5], "height": 3 }]
      }
    }
  },
  "timeline": { "duration": 6, "loop": "once" }
}
A dam breaks. Water floods round a static block and carries a floating crate. apps/docs/examples/flood.json · render it with motion-sdk render apps/docs/examples/flood.json -t 1 -o flood.png
  • The area is size wide on x and z, centred on the node and aligned with the world. Put the node at the floor's height. The basin floor is the physics ground.
  • cells sets the detail along the longer side, from 8 to 160. The default is 64. More is finer and slower.
  • edges: "open" drains water at the border. The default closed keeps it in.
  • A dynamic body's buoyancy sets how it floats. 1 rides half under, 2 bobs high, and below 0.5 sinks.
  • Give the surface a water material.
  • Like physics, the flood is simulated once when the scene loads, so it scrubs like keyframes. In the browser it needs the authoring bundle.

See examples/physics-flood.json for a flash flood through a street.

API Reference

Water

Waves and reflections for a water (or wet, mirror-like) surface.

PropertyTypeDefaultDescription
reflectnumber (0 to 1)1Reflection strength (0 to 1).
scalenumber (≥ 0.01)3Wavelength of the biggest waves, in world units.
speednumber (0 to 20)1How fast the waves move (1 is a gentle swell).
wavesnumber (0 to 2)0.35Wave strength: 0 is a still mirror (wet tarmac, a calm pond), 1 is choppy.

Flood

Simulated water over an area centred on the node and aligned with world x and z: it pours in from sources, spills from fill blocks, flows downhill around static bodies and over terrain, and floats dynamic bodies (see buoyancy). Simulated once on load with the bodies, so it scrubs like keyframes. The basin floor is the physics ground (or the node's height without one); put the node at the floor's height.

PropertyTypeDefaultDescription
cellsinteger64Grid cells along the longer side (8..160). More is finer and slower.
edgesFloodEdges—What the area's border does: walls keep water in, open drains.
fillFloodFill[]—Blocks of water standing at the start, held by nothing: a dam breaking, a wave from one side.
levelnumber—Starting still-water surface height above the node (none: dry).
materialstring—Material for the surface (a water material looks best).
size*[x, y]requiredWidth (x) and depth (z) of the area, world units.
sourcesFloodSource[]—Places water pours in: a burst main, a river mouth, rain on a spot.

FloodFill

A box of standing water at the start of a [Flood], in the node's local x/z.

PropertyTypeDefaultDescription
from*[x, y]requiredCorners [x, z].
height*numberrequiredSurface height above the node.
to*[x, y]requiredThe opposite corner [x, z]. Must be past from on both axes.

FloodSource

Water pouring into a [Flood] over a disc.

PropertyTypeDefaultDescription
durationnumber—How long it runs, seconds (none: to the end).
position*[x, y]requiredCentre [x, z] in the node's local space.
radiusnumber1Radius of the disc the water pours in over, in world units.
ratenumber4Cubic metres per second.
startnumber—When it starts, seconds.

FloodEdges

The border of a [Flood].

ValueDescription
"closed"Water stays in (it piles up against the border).
"open"Water runs off and is gone.