Lookup

Use one input's values as indices into another array, collection, or image.

What it does

Lookup uses one input's values as keys to fetch elements out of another. Wire the keys into Index and the table to gather from into Data; each key returns its matching element, one output value per key. Index and Data accept a plain array of numbers, a Collection read through a chosen attribute, or an image, where the Index image's pixel values pick coordinates to sample the Data image.

Out-of-range keys are resolved by Wrap: clamp to the ends, repeat/tile, or mirror/ping-pong. Interpolation chooses between snapping to the nearest element and blending between neighbours, which builds a smooth gradient or palette lookup from a short table.

When to use it

ParameterTypeDefault
indexOneOf([Number, NumberArray, IntArray, Collection, FieldOf(Raster)])
dataOneOf([NumberArray, Vec2Array, Vec3Array, ColorArray, IntArray, Collection, FieldOf(Raster)])
index_attributeString"index"
source_attributeString"Cd"
source_typeString"Color"
source_channelString"Luminance"
index_modeString"Integer"
wrapString"Clamp"
interpolationString"Nearest"
strengthNumber1

Gotchas

Set Index Mode to Normalized when the keys are 0–1 fractions rather than whole-number positions. They are then scaled by the table length.

Both Index and Data must be connected. With either pin unwired the node passes its input through untouched.

When Index or Data is a Collection, the values used come from the Index Attribute / Source Attribute and Source Type knobs, not the Collection as a whole. Pick the attribute holding the keys (for example id, u) and the one holding the values to gather (for example Cd, P), and set Source Type to match its shape (Number/Vec2/Vec3/Color).

Worked example

  1. Add a Lookup. Wire an array or Collection of keys into Index, and the table to sample into Data.

  2. If Index or Data is a Collection, set Index Attribute / Source Attribute (and Source Type) to the attributes holding the keys and values.

  3. Set Wrap and Interpolation for out-of-range and in-between keys. Linear interpolation gives a smooth gradient lookup from a short table.

  4. For an image-driven remap, wire two images into Index and Data. The Index image's Source Channel picks the sample position on the Data image.

See also

Sample · Gradient · Select · Collections