Builtin Library
README.md
subsurface
Light that enters a surface at one point and leaves at another — the transport that softens and warms the terminator on skin.
local subsurface = require("@builtin::systems.subsurfaceScattering.subsurface")
subsurface.mark(headId, { color = { 1, 0.3, 0.16 }, radius = 0.02 })
subsurface.unmark(headId) --> true when it had been marked
subsurface.marked(headId) --> { color, radius }, or nil
subsurface.list() --> every entity scattering, sorted
subsurface.groups() --> the marked set gathered by what it scatters
subsurface.setStrength(0.7) --> how much of the spread reaches the frame
subsurface.active() --> is the pass running
subsurface.clear() --> unmark everything, release the pass
mark on an entity that is already marked replaces what it scatters. A radius
below zero is an error rather than a silent clamp, and an entity that does not
exist is an error rather than a mark that never draws. The pass is created with
the first mark and released with the last.
groups is what the render feature draws from: meshes sharing a tint and a
radius are one draw, so per-entity scattering costs one pass per distinct
setting rather than one per mesh. It also drops entities that have since been
despawned, so a removed character does not keep its group alive.
For scattering a scene should simply have, author the SubsurfaceScattering
component instead — same settings, persists with the scene, edits live in the
inspector.
The full description of the knobs and how the passes work is in the package
readme: guides { path = "systems/subsurfaceScattering" }.