Motion SDK

Textures

Images on materials for logos, signs, screens, posters and tiles.

Declare each image once in textures, then map it onto a material with map (colour) or emissive_map (light).

A checker PNG tiled 6x6 on the floor and lit as a screen.
{
  "camera": { "position": [0, 2.2, 6.5], "target": [0, 0.8, 0], "fov": 40 },
  "lighting": { "rig": "studio_soft" },
  "environment": {
    "background": {
      "radial_gradient": { "inner": "#1b2233", "outer": "#07090f" }
    }
  },
  "post": { "bloom": 0.5 },
  "textures": {
    "checker": {
      "src": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAJElEQVR42mMQEZGDo/96R+AIlzjDINRAjCJk8cGoYTQeBoUGAFD+G5A9c+hMAAAAAElFTkSuQmCC"
    }
  },
  "materials": {
    "tiles": {
      "color": "#9aa0b0",
      "roughness": 0.6,
      "map": { "texture": "checker", "repeat": [6, 6] }
    },
    "screen": {
      "color": "#000000",
      "emissive": "#ffffff",
      "emissive_intensity": 2,
      "emissive_map": { "texture": "checker", "repeat": [2, 1] }
    }
  },
  "nodes": {
    "floor": {
      "mesh": {
        "geometry": { "plane": { "size": [6, 6] } },
        "material": "tiles"
      },
      "transform": { "rotation": [-90, 0, 0] }
    },
    "sign": {
      "transform": { "position": [0, 1.3, -1] },
      "mesh": {
        "geometry": { "plane": { "size": [2.4, 1.4] } },
        "material": "screen"
      }
    }
  }
}
A checker PNG tiled 6x6 on the floor and lit as a screen. apps/docs/examples/textures.json · render it with motion-sdk render apps/docs/examples/textures.json -t 1 -o textures.png

Sources

src is a PNG or JPEG data URI, a path next to the scene file, or an https URL in the browser. In the browser, relative paths resolve against textureBase. Until an image loads, the material draws as plain colour.

Gradients

A src can also be a CSS-style gradient. The renderer generates it, so there's no file to load, and it maps with the geometry's UVs like an image.

scene.json
{
  "textures": {
    "sunrise": { "src": "linear-gradient(135deg, #ff6a3d, #ffb347 45%, #4a3f9a)" },
    "glow": { "src": "radial-gradient(at 50% 40%, #ffffff, #0a84ff 55%, #001a4a)" }
  }
}
  • linear-gradient(<angle>, <stops>) uses CSS angles. 0deg points up, 90deg right, and the default 180deg runs top to bottom.
  • radial-gradient(<stops>) is a circle from the centre to the nearest edge. at 30% 20% moves the centre.
  • Stops are hex colours with an optional % position. Stops without one spread evenly. Colours blend in sRGB, like browsers.
  • A gradient that doesn't parse is an invalid_gradient error.

See 2D Motion Graphics for gradient cards.

Patterns

A src can also be a procedural art-media pattern, which the renderer generates like a gradient. Patterns are near-white greys that multiply the material or node colour, and they tile seamlessly, so repeat sets their scale.

scene.json
{
  "textures": {
    "paper": { "src": "paper(0.25)" },
    "wash": { "src": "watercolor(0.4, 3)" },
    "dry": { "src": "bristle(0.6)" }
  }
}
  • paper(<amount>) is fibrous paper grain.
  • watercolor(<amount>) gives soft pigment blotches, granulation and darker pooled edges.
  • bristle(<amount>) draws streaks along U, with dry-brush gaps that open towards U = 1. Brush strokes run U along their length (see Brush Ink and Paper).
  • amount runs from 0 to 1. An optional whole-number seed comes second: paper(0.25, 7).
  • A pattern that doesn't parse is an invalid_pattern error. Patterns come with the authoring bundle in the browser.

Mapping

  • map multiplies color, so keep color white for the image's own colours. Its alpha cuts the material out.
  • emissive_map multiplies emissive, for lit signs, screens and windows.
  • repeat, offset and rotation (degrees) transform the UVs.
  • Planes show the image upright, facing +z.

API Reference

Texture

An image the scene loads once and materials map by name.

PropertyTypeDefaultDescription
src*stringrequiredPNG or JPEG: a data:image/...;base64, URI, an https:// URL (browser only; the CLI reads data URIs and files), or a file path relative to the scene. Or a CSS-style gradient the renderer generates (no file): linear-gradient(90deg, #0a84ff, #ffffff00 80%), radial-gradient(at 50% 40%, #ffffff, #0a84ff).

TextureMap

Where a texture lands on a surface: uv' = rotate(uv * repeat) + offset.

PropertyTypeDefaultDescription
offset[x, y]—Shift in UV units, applied after repeat and rotation.
repeat[x, y]—Tiles across U and V (images wrap).
rotationnumber—Rotation in degrees, counter-clockwise around UV (0, 0).
texture*stringrequiredName in the scene's textures.