Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

sim.flipbook (procNode)

Texture-sheet animation for particles: which cell of a sheet each point shows, from its age. A sheet is columns by rows cells, counted row by row from the top-left, of which the first frames are frames. The node writes the data0 lane of every point as (frame, next frame, how far between them, 0) and the data1 lane as (columns, rows, 0, 0), the lanes the flipbook shader reads. Any shader that reads those two lanes plays the sheet.

  • loop runs the frames again and again at framerate.
  • pingPong runs them forward and back.
  • oneShot plays the whole sheet once over each particle's lifetime, however long that is.
  • random shows one frame chosen for each particle: a new one at every tick of framerate, the first one held with a framerate of 0.

framerate is drawn between its x and y for each particle. startRandom starts every particle at a frame of its own, so a crowd of them plays out of step; it shifts loop and pingPong, and oneShot always starts at the first frame. blend fades between a frame and the next; off, the playback cuts from one to the next, and random always cuts. The points need age and lifetime, which sim.particles gives them, and a cook on points without either is refused; id, where each particle is to draw its own random numbers, falls back to each point's place in the set.

Built from field.index, attribute.set, rand.unit and the field math nodes.

Inputs

  • points (Points): the points that show the sheet.
  • columns (Float, default 4, min 1): cells across the sheet. 1 by 1 is a sheet of one picture.
  • rows (Float, default 4, min 1): cells down the sheet.
  • frames (Float, default 0, min 0): how many cells are frames; 0 takes every cell.
  • mode (String, default "loop"): "loop", "oneShot", "pingPong" or "random".
  • framerate (Vec2, default (24, 24)): frames a second, drawn between x and y for each particle. oneShot ignores it.
  • startRandom (Bool, default false): start each particle at a frame of its own.
  • blend (Bool, default false): fade between a frame and the next.
  • seed (Float, default 0): which of the possible random choices the particles make.

Outputs

  • points (Points): the points with the point attributes data0 and data1.

Example

local source = g.sim.spawn({ points = g.points.grid({ countX = 1, countZ = 1 }), rate = 30 })
local sim = g.sim.particles({ sources = { source } })
local sheet = g.sim.flipbook({ points = sim.points, columns = 4, rows = 4, mode = "loop", framerate = { x = 12, y = 24 } })