Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit0a13e47b57

README.md

Scene light (asset type)

A scene light is one light that reaches the whole scene alike, as an asset. It is one position-independent Light (directional, ambient or distant, the kinds lighting.isPositionIndependent answers for) described in sceneLight.yaml, and it implements applicable: applying it puts that light in force for the applier.

Where it lives

  • Source: <name>.sceneLight/
  • Identity: <name> (the .sceneLight suffix strips from the identity)
  • Folder shape:
    • sceneLight.yaml: the light. Required.
    • README.md: what light it puts on a scene. Required.
    • .metadata: description and tags. Required.
# moonFill.sceneLight / sceneLight.yaml
kind: distant
direction: [0.3, -0.5, 0.4]
color: [0.6, 0.7, 1.0]
intensity: 0.3

Parameters

Its parameters are the Light component's own fields for the light, with their descriptors (intensity, colorR/colorG/colorB, directionX/Y/Z, castsShadows, lightChannels, mobility), defaulting to what sceneLight.yaml states, and three of its own:

  • followSky: whether the sky orients this light (a directional or distant one). A sky that drives the sun (a procedural backdrop) then writes the light's direction from its hour, and its colour and intensity as the stated ones multiplied by the curve of the sun's elevation: the stated intensity is the noon peak, reached from 30° up; toward the horizon the light dims and warms (about 0.3 of the peak at 7°), and below it the intensity is 0. A sun that should follow the sky states followSky: true and no direction.
  • skyOffset: where a following light stands from the sun, [yaw, pitch] in degrees. Yaw turns it about the vertical, so [180, 0] is a fill from the side opposite the sun at the sun's elevation; pitch raises it above the sun. The curve is the sun's, so a fill dims with the sun and is out at night.
  • followSkyIntensity (default true): whether a following light takes its intensity from the sky as well as its direction and colour. true puts the sun's curve on the stated intensity, as above. false keeps the stated intensity while the light stands above the horizon (its own elevation, after skyOffset) and 0 below it; the direction and the colour still come from the sky. A sun follows with it true; a fill or a rim that should hold its strength through dusk states it false. After dark a following light stands at the moon the sky draws, opposite the sun: with true it is out, with false it is moonlight at the intensity it states.

A cool fill for a dusk scene: it stands opposite the sun, a little higher, takes the sky's direction and its warm-to-cool colour, and lands at the 0.9 it states at 17:42, where with followSkyIntensity true it would land near 0.18.

# harbourFill.sceneLight / sceneLight.yaml
kind: distant
color: [0.5, 0.6, 1.0]
intensity: 0.9
castsShadows: false
followSky: true
followSkyIntensity: false
skyOffset: [180, 12]

What a following light lands at is not what it states. A placed setup's SceneSetup:members() reports, for such a member, landed (its intensity, colour and direction now) beside stated, and SceneSetup:get(path) carries landed beside value for each of those parameters; SceneSetup:set(path, value) returns that read, so setting fill/intensity answers what it lands at straight away, and the setup's card shows it on the row (0.9 → lands at 0.18 at 17:42). ref:landed(owner) is the same answer for one application.

Applying it

Each application spawns a temporary entity of its own (ref:entityOf(owner)) and puts a Light of the asset's kind on it; it publishes itself as the sun or the ambient term the way every Light does, and the last to publish holds it. Dropping the application removes the Light and the entity. The ApplyState reports held while another light holds its kind (heldBy names that application's owner, or the holding entity), and a notice when an ambient term is as bright as half the sun or more, which flattens the scene's shading. A write the lighting API makes to the light (lighting.setSun, lighting.setAmbient, sky.setSunDirection) lands on the application, through its owner's writer when it handed one.

A kind that lights from where its entity stands (point, spot) is refused by name (sceneLight.kind).