Builtin Library
README.md
core.normals.corner (procNode)
A normal for every vertex that smooths across the primitives around its point where they meet at less than a crease angle, and keeps an edge hard where they meet at more.
Built from core.normals.face, core.adjacency (the vertices standing on each point), core.owner, core.corners (for the angle a primitive turns through at a vertex), the expand kernel (one slot per primitive around the vertex's point), gather, math.dot, math.where and scatter with an add fold, then math.normalize. A vertex takes the sum of the normals of the primitives around its point whose normal is within angle degrees of its own primitive's, each weighted by area, by the angle the primitive turns through at the point, or equally. Written as N on the vertex class.
Inputs
geometry(Geometry). The geometry whose vertices get normals.angle(Number). Default60. 0 to 180. The crease angle: primitives around a point whose normals differ from a vertex's own by no more than this are smoothed into it.weighting(one of area, angle, uniform). Default"area". How each primitive counts in the average: by its size, by the angle it turns through at the point (which leaves the normal the same however the surface around the point is cut into triangles), or equally.name(String). Default"N". The attribute the normals are written under on the vertex class.
Outputs
geometry: the geometry with a normal on every vertex.
Example
local grid = g.mesh.grid({ size = { x = 2, z = 2 }, cells = { x = 2, z = 2 } })
local shaded = g.core.normals.corner({ geometry = grid, angle = 30 })
Every vertex of the flat grid has the normal (0, 1, 0).