ludic/docs/language/light/light-ambient.md
Orkuncakilkaya a71279a7b9
All checks were successful
bootstrap / cfree-fixpoint (push) Successful in 18s
ci / build-and-test (push) Successful in 1m13s
commit-lint / conventional-commits (push) Successful in 5s
docs / build-and-deploy (push) Successful in 18s
feat(rendering): add Light.* — deterministic 2D light accumulation with hard shadows (#4)
A software light pass over the framebuffer, run in a render phase after drawing
the scene: Light.ambient multiplies the scene toward a tint (night/cave mood),
Light.point additively accumulates a radial glow with linear falloff clamped per
channel, and Light.occlude / Light.clear_occluders cast hard shadows by blocking
a light's rays against rectangular occluders. Integer + Q16.16 fixed throughout,
so a scene lights identically every run and in a headless render (diffable).

Engine in runtime/native/light.ludic, spliced on demand (g_uses_light) like the
regex/query runtimes; namespace wired in emit_call.ludic. Ships issue #4 tiers 1
(ambient + additive radial lights) and 2 (hard shadows). Normal-mapped sprites,
soft shadows, a day/night directional light, and auto-consuming Light2D/Occluder
components are follow-ups (the auto-system hook is tracked by #43).

- runtime/native/light.ludic: the light-accumulation engine (isqrt falloff,
  segment/occluder shadow test, ambient modulate)
- examples/library/lighting.ludic: 14 pixel-readback assertions
- docs/language/light/: Light.ambient/point/occlude/clear_occluders
- tools/x/test.ludic: lighting.ludic in the regression suite

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-31 14:07:19 +03:00

1.1 KiB

id name category kind tokens sig tip order ns member
light-ambient Light.ambient light namespace-method Light.ambient Light.ambient(color) Multiply the whole scene by a tint — the night/cave modulate. 1 Light ambient

Multiplies every framebuffer pixel by color (a 0x00RRGGBB tint), channel by channel (channel * tint / 255). This is the global modulate that sets mood before any light adds brightness back: a dim blue-grey gives night, a warm brown gives a cave, and 0xFFFFFF is a no-op. Call it once, after drawing the scene and before the Light.point calls that light it back up.

Parameters:

  • color — the ambient tint, 0x00RRGGBB (darker/cooler = a darker scene)
program Demo {
  property Tag { v: int = 0 }
  model Marker { Tag }
  handler Render phase Update {
    Screen.clear(Color.rgb(120, 120, 140))
    Light.ambient(Color.rgb(48, 48, 72))   # dusk: dim and cool
    Light.point(160, 120, 90, Color.Amber, 1.0)
    Screen.show()
  }
}