Builtin Library
README.md
ParticipatingMedium
Marks its entity as a volume of fog, smoke, dust or steam — something light has to travel through. What is behind the volume comes out dimmer than what is beside it, and overlapping volumes stack.
local id = entity.spawn("fog_bank").id
entity(id).component.add("ParticipatingMedium", {
sizeX = 30, sizeY = 8, sizeZ = 30,
density = 0.15,
})
Fields
| Field | Meaning |
|---|---|
shape | "box" (default) or "sphere" |
density | Extinction per world unit. 0 releases the medium. |
sizeX / sizeY / sizeZ | Half-extents, for a box |
radius | Radius, for a sphere |
density is the physical knob: a ray crossing d world units of a medium of
density k leaves with exp(-k * d) of the light it entered with. A 20-unit
bank at 0.15 therefore passes about 5% of the light straight through it.
The entity's position places the volume; move the entity and the shadow moves with it.
Notes
- The light-space map is sized to the bounding sphere of everything registered.
A small bank sharing a scene with a very large one lands on few texels — set
extentandcentrethroughmediaTransmittance.setto bias the map toward the region you care about. - Attenuation applies to surfaces. The sky keeps its own colour.
- The attenuated light is the sun's:
sunDirectionsets which way the map's rays travel.
See mediaTransmittance for the scene-wide settings and the direct API.