Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

field.ramp

A ramp read at every element. The value (t, or else the element's own by attribute) is taken from range onto 0..1 by field.map_range, and ramp.sample reads the ramp there. A value past either end of range reads that end of the ramp. By default each element reads by its own life, so particles change over their lifetime.

Inputs

  • ramp (Ramp). The ramp to read.
  • t (Field<Float> | Float, optional). Where along the ramp each element reads. Left unwired, it is the element's own by attribute.
  • by (String). Default "life". The Float attribute each element reads the ramp by when t is unwired. A particle solver's particles carry life, 0 at birth to 1 at death.
  • range (Vec2). Default { x = 0, y = 1 }. The values of t that land at 0 and at 1 on the ramp (x and y), so a speed from 0 to 20 or a temperature from 300 to 3000 reads the whole ramp.

Outputs

  • field: a field of the ramp's value type.

Example

local points = g.points.grid({ countX = 4, countZ = 1, spacing = 1 })
local ramp = g.ramp.keys({ type = "Float", keys = { { t = 0, value = 0 }, { t = 1, value = 10 } } })
local out = g.attribute.set({ geometry = points, name = "v", value = g.field.ramp({ ramp = ramp, t = g.field.position().x, range = { x = 0, y = 3 } }) })

x from 0 to 3 reads the ramp from 0 to 10: the points at -1.5 and -0.5 read 0, the one at 1.5 reads 5.