irradianceField
The light spilling from a shape's edges, gathered once into a texture and read per pixel.
irradianceField(spec: IrradianceFieldSpec): {
compute: GpuComputeNode
sample: (params: GpuFragmentParams) => Expr | undefined
}
Import radiance from shaders/std and use radiance.irradianceField.
Returns two halves. Put compute on your definition's compute: field. In your material, call sample(params) for the rgb light at the pixel. It returns undefined when there is no GPU to gather on, so write sample(params) ?? splat3(0). It reads your standard shape props (center, scale, rotation, shape, shapeSdfUrl, shapeType) plus the props named in the spec. The texture only re-gathers when a light or the shape changes.
Parameters
| Name | Type | Notes |
|---|---|---|
spec | IrradianceFieldSpec |
Example
const spill = irradianceField(GATHER).sample(params) ?? math.splat3(0)
Tip. Build the spec once as a constant and use it for both
compute:andsample.
See also
gatherIrradiance— The light arriving at a pixel from a glowing shape edge, with the shape's body blocking it.shadowVisibility— How much of a light reaches a point, 1 when nothing is in the way and 0 when the shape blocks it.