Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

field.mix

Per-component linear blend a + (b - a) * t. t is a number or a field read per element, so the blend can vary across the domain. A number b stands for every component; a component a has that a vector b lacks blends toward 0.

Inputs

  • a (Field | Float | Vec2 | Vec3 | Vec4). The value at t = 0. The output carries a's type and component count.
  • b (Field | Float | Vec2 | Vec3 | Vec4). The value at t = 1.
  • t (Field | Float). Default 0.5. Where between a and b each element lands: 0 gives a, 1 gives b, 0.25 sits a quarter of the way across. A field makes the blend vary across the domain; values outside 0 to 1 carry the line past its ends.

Outputs

  • field: a field of a's type and component count.

Example

local points = g.points.grid({ countX = 4, countZ = 1, spacing = 1 })
local out = g.attribute.set({ geometry = points, name = "v", value = g.field.mix({ a = vector.create(0, 0, 0), b = vector.create(10, 0, 0), t = g.element.id / 3 }) })

v runs from (0, 0, 0) to (10, 0, 0) across the four points.