Builtin Library
README.md
core.sample.surface (procNode)
Choose points on a surface, area-weighted and deterministic: the face and the barycentric place of each, as samples.
Built from core.owner, core.normals.face, the expand kernel (each primitive fanned into triangles), gather, math operators for the triangle areas, an inclusive scan of the areas, field.random draws, the search kernel (the triangle each draw falls in) and core.points. The result is Points with P, prim (the primitive), ia, ib, ic (the three vertices of the triangle), bary (the weights of those vertices) and N (the primitive's normal). core.interpolate carries a geometry's attributes to such samples.
Inputs
geometry(Geometry). The surface sampled.count(Number). Default256. At least 0. How many samples.seed(Number). Default1. Which of the possible layouts this is.graphId(String). Default"". The graph the draws are keyed to, so two graphs with one seed draw different places.nodeId(String). Default"". The node the draws are keyed to.
Outputs
samples: points withP,N,bary,prim,ia,ib,ic.
Example
local grid = g.mesh.grid({ size = { x = 2, z = 2 }, cells = { x = 2, z = 2 } })
local samples = g.core.sample.surface({ geometry = grid, count = 16, seed = 3 })
16 samples on the grid's triangles, each with P, N, prim, ia, ib, ic and bary.