Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

core.raster.sample (procNode)

Sample a layer at world positions with a bilinear blend of the four cells around each, reading the cells the raster holds past the field for a position beside it, and holding the last cell past everything the tiles hold.

Built from core.raster.read (held), g.field.gather and math.lerp, as a field over whatever elements the positions come from.

Inputs

  • raster (Raster). The raster sampled.
  • layer (String). Default "height". The layer sampled.
  • at (Value). The positions sampled: a Vec3 field or column, read by x and z.

Outputs

  • value: a Float field of the blended layer value at each position.
  • count: the cells of the field.

Example

local raster = g.core.raster.new({ size = { x = 8, z = 8 }, resolution = 1, layers = { "height" } })
local raised = g.core.raster.blend({ raster = raster, value = 3.0 })
local probes = g.points.grid({ countX = 2, countZ = 1 })
local sampled = g.attribute.set({ geometry = probes, name = "h", value = g.core.raster.sample({ raster = raised, at = g.field.position() }).value })

Both points read the height 3.