Skip to content

feat(lighting): add RGB colored light rendering - #77

Merged
zoeyrose merged 6 commits into
mainfrom
feat/colored-lighting-75
Aug 10, 2026
Merged

zoeyrose merged 6 commits into
mainfrom
feat/colored-lighting-75

Conversation

@zoeyrose

@zoeyrose zoeyrose commented Aug 10, 2026 •

Copy link
Copy Markdown
Member

Summary

  • add strict light_color RRGGBB object support, fixed-point RGB propagation, live Python mutation hooks, and colored applied-light behavior while preserving scalar gameplay visibility
  • extend MAP2 protocol v1075 with sparse RGB samples and ordered, bounded continuation packets
  • render per-channel smooth lighting across ground, walls, roofs, objects, fog boundaries, and linked depths, with coherent discrete fallback and stale-state resets
  • add server, protocol, client-state, Python lifecycle, and deterministic pixel-exact regressions

Protocol and compatibility

  • Classic protocol advances from 1074 to 1075 and retains exact-version rejection.
  • MAP2_FLAG_EXT_LIGHT_RGB follows the complete seven-bit field bitmap and precedes animation data. A zero bitmap resets prior explicit color to scalar gray.
  • Full packets declare a uint16_t continuation count; partial packets carry ordered sequence/map/scroll identity. Level payloads are capped at 65,522 bytes so the 7-byte partial header plus 5-byte level frame remain within the 65,534-byte envelope.

Performance and limits

Measurements were taken on this runner at Classic base fca1eb0e and head 52d85b4b; client timings use Release builds and 100 samples after five warmups around the single map_draw_map() call in the frozen 320×240 software-renderer fixture. Server microbenchmarks use the Debug test build, a 21×21 map, and 1,000 iterations.

Surface Ordinary / before Colored or dense / after Bound and interpretation
Frozen full MAP2 fixture 325 B at v1074 327 B neutral; 525 B colored multi-depth Neutral cost is +2 B (+0.62%) for continuation count; color remains sparse.
Live ordinary room MAP2 11,128 B full; 46 B unchanged; 1,116 B one-tile scroll 2,277 B initial red; 48 B same-level hue change; 37 B neutral reset Delta-only hue/reset packets remain small; neutral scrolling has no per-tile RGB payload.
Dense 21×21 producer n/a 116,909 B across 2 payloads; largest 65,487 B Every payload is below 65,534 B; validation proves ordered complete tile records.
Server source update pair 15.17 µs neutral remove/add 47.21 µs colored remove/add +32.04 µs per authored colored update; no frame-loop scan is introduced.
Server full rebuild 12.69 µs neutral 28.84 µs colored +16.15 µs for one radius-13 source on 21×21; work stays source/mask bounded.
Client lighting frame 29.25 ms base neutral 32.97 ms current neutral; 32.77 ms colored Head is +3.72 ms (+12.7%) versus base and colored adds no further cost in this fixture; bounded below 4 ms regression.
Sample buffers, one 320×240 active depth 308,080 B 615,920 B +307,840 B; the 307,200-byte RGBA lightmap is unchanged.
Sample buffers, all 13 depths 4,005,040 B 8,006,960 B +4,001,920 B (3.82 MiB); inactive-depth contexts are freed.
Lit-sprite cache, first frozen frame 1 hit / 3 misses neutral 1 hit / 10 misses colored multi-depth More unique RGB signatures correctly create distinct entries. Exact signatures are reusable; LRU remains capped at 8 MiB per active depth and inactive-depth caches are freed.

The measured costs are bounded and intentional: neutral wire traffic is effectively unchanged, RGB work is limited to explicitly colored state, and the largest client delta is under 4 ms in the deterministic software-renderer fixture.

Validation

  • ./atrinik build all --profile issue-75-colored-lighting --test
  • protocol: 2/2 passed
  • libatrinik: 14/14 passed, including loopback socket/curl/STUN coverage
  • client: 30/30 passed, including map color-state and smooth/discrete pixel-exact player views
  • server: 36/36 passed, including lighting, dense MAP2, applied-light, and Python mutation/persistence coverage
  • content companion: python3 tools/validate.py passed 89/89
  • python3 tools/verify_import_history.py: verified five imported histories
  • all changed C headers/sources pass clang-format --dry-run --Werror; git diff --check passes
  • isolated topology issue75-colored, profile issue-75-colored-lighting, state scenario-issue75-colored: latest Classic/content heads resolved cleanly, server ready, client completed the QUIC handshake and opened its asset stream; topology stopped afterward

Companion change

Closes #75

@zoeyrose zoeyrose moved this to Review in Atrinik work Aug 10, 2026
@zoeyrose
zoeyrose marked this pull request as ready for review August 10, 2026 10:37
zoeyrose added a commit to atrinik/content that referenced this pull request Aug 10, 2026
## Summary

- add the exact six-digit `object.light_color` authored-content field
and regenerate schema/editor projections
- give representative wall torches and red/blue forcefields explicit
light colors
- cover schema constraints, Gridarta exposure, Python RGB bounds, live
mutation paths, applied-item propagation, and save/load persistence
- preserve the immutable provenance of the historical authored-syntax
benchmark while advancing the current baseline lock

## Validation

- `python3 tools/validate.py`: 89/89 tests passed, including aggregate
schema/catalog/runtime/package checks
- generated authored-content projections are current
- companion Classic profile build consumed content HEAD
`2d7c68b178d6a3d5b94d6c2bedfa0c6fa6e4c77c`
- `git diff --check` passes and the worktree is clean
- fresh whole-diff review found zero actionable findings

Companion to atrinik/classic#75 and atrinik/classic#77. The Classic PR
is the canonical closing change.
@zoeyrose
zoeyrose merged commit 4b61beb into main Aug 10, 2026
17 checks passed
@github-project-automation github-project-automation Bot moved this from Review to Done in Atrinik work Aug 10, 2026
@zoeyrose
zoeyrose deleted the feat/colored-lighting-75 branch August 10, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat(lighting): blend multiple colored light sources

1 participant