The remaining lighting tiers from the original proposal, all extending the deterministic accumulation core (light.ludic) — no new ECS plumbing: - Light.spot: cone / flashlight lights (direction + spread degrees), with a self-contained integer atan2-in-degrees and a feathered edge. - Light.falloff: a brightness-ramp exponent (1 linear, 2 quadratic, …) via repeated fixed multiply. - Light.soft: soft shadows — an area-sampled light so an occluder edge fades through a penumbra instead of a hard cut. - Light.gel + Light.clear_gel: colour cookies — a light gels from its centre colour to a rim colour. - Light.normal + Light.clear_normals + Light.height: a normal G-buffer so surfaces shade by facing (N·L), not distance alone (tier 3). - Light.time_of_day: a day/night ambient ramp from a single 0..1 value. The engine lighting system (systems_light.ludic) consumes matching optional Light2D fields — direction/spread/falloff/softness/gel — each defaulting off so an older five-field Light2D lights exactly as before. Every tier is integer + Q16.16 fixed, so scenes light identically on every run and headless. Worked example + regression: examples/library/light_tiers.ludic (1 1 1 1 1 1 1 1 1). Nine new docs/language/light pages. Full suite 76 passed, self-host C-free fixpoint intact, no golden drift. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
33 lines
1.4 KiB
Markdown
33 lines
1.4 KiB
Markdown
---
|
|
id: light-soft
|
|
name: Light.soft
|
|
category: light
|
|
kind: namespace-method
|
|
tokens: Light.soft
|
|
sig: Light.soft(radius)
|
|
tip: Soft shadows — an occluder edge fades through a penumbra of this radius.
|
|
order: 7
|
|
ns: Light
|
|
member: soft
|
|
---
|
|
|
|
Turns on **soft shadows** for lights emitted after it. A hard shadow tests a single ray from the light centre to each pixel, so an <a href="light-occlude"><code>occluder</code></a> edge cuts sharply. With <code>radius > 0</code> the light is treated as a small disk of that radius: each pixel samples visibility from a cross of points across the disk and averages them, so the shadow edge fades through a **penumbra** instead of a hard line. <code>Light.soft(0)</code> restores hard, single-sample shadows. The setting persists until changed. Deterministic (fixed-point average of integer ray tests).
|
|
|
|
Parameters:
|
|
- `radius` — the light's apparent size in pixels; larger = wider penumbra (`0` = hard)
|
|
|
|
```ludic
|
|
program Demo {
|
|
property Torch { x: int = 0, y: int = 0 }
|
|
model Lamp { Torch }
|
|
handler Render phase Update {
|
|
Screen.clear(0)
|
|
Light.ambient(Color.rgb(24, 24, 32))
|
|
Light.clear_occluders()
|
|
Light.occlude(96, 40, 6, 40) # a pillar casting a shadow
|
|
Light.soft(5) # 5px penumbra
|
|
Light.point(60, 60, 90, Color.rgb(255, 240, 200), 1.0)
|
|
Screen.show()
|
|
}
|
|
}
|
|
```
|