Builtin Library
README.md
ramp
A ramp is a value that changes over 0..1. It is how an effect makes one thing follow another: colour over life, size over speed, opacity over height.
procgen.searchNodes("", { pack = "ramp" }) lists the family and procgen.describeNode("op.<id>")
describes any one of them.
Ops
ramp.keys— a ramp built from keys. Each key is{ t = <0..1>, value = ... }, andtypesays what the value is: aFloat,Color({ r, g, b, a }),Vec2,Vec3orVec4({ x, y, z, w }). Keys are laid out intorder whatever order they are written in. Between keys the value moves in one of three ways:linear: a straight line from key to key;smooth: eased into and out of each key;constant: each key's value held until the next key.
ramp.blackbody— the colours a blackbody glows at across a temperature range, as a Color ramp: deep red at the cool end through orange and white to blue at the hot, overfromtotokelvin.glowmakes the hotter keys brighter; 4 follows the fourth power of temperature that real blackbody radiance does.ramp.sample— a ramp read at every element, at the position along it the 0..1 field wired intounames; a value past either end reads that end. The ramp compiles to the element's dispatch, so a solver's particles read it on the device.
field.ramp (g.field.ramp), a node of the field nodebox, reads a ramp at
every element by a value it carries: a graph of field.attribute,
field.map_range and ramp.sample. By default each element reads it by its
own life attribute, so particles change over their lifetime. by names any
other attribute, range maps that attribute's values onto 0..1, and wiring t
reads the ramp by any field.
A ramp is a graph value like any other. It can be wired, animated (its keys are params) and cached.
Particles coloured by their heat over their life:
local fire = g.op.ramp.blackbody({ from = 900, to = 4000, glow = 1 })
local life = g.op.field.attribute({ name = "life" })
local lit = g.op.attribute.set({ domain = sparks, name = "Cd", value = g.op.ramp.sample({ ramp = fire, u = life }) })