Skip to content

Bake indirect light per area and hang troffer fixtures - #40

Merged
valuecodes merged 3 commits into
mainfrom
feat/photoreal-lighting
Oct 13, 2026
Merged

valuecodes merged 3 commits into
mainfrom
feat/photoreal-lighting

Conversation

@valuecodes

Copy link
Copy Markdown
Owner

What

  • Part 2/2 of Toward a photorealistic Code Backrooms: light that behaves like the real place. Each area's walls, floor and ceiling now get a baked lightmap holding one bounce of the fixtures' light plus a fill that corners and junctions occlude, instead of the flat ambientLight.
  • The bake runs in a worker (bake.worker.ts, three-mesh-bvh ray casts), one area at a time, keyed by the area object so a reseed or regeneration never receives a stale map. Unbaked areas use a flat 1×1 placeholder map. Placeholder and baked maps share channel, type and format, so a bake landing recompiles no shader (pinned by a test).
  • Fixtures are now surface-mounted 2×4 troffers (an enamel housing with an inset diffuser). The fixtures over the player's room also get one of two always-mounted RectAreaLights, for the panel's real shape in the floor's sheen. These take 60 % of the fixture's light; the point light keeps the rest and still casts the shadow.
  • Cost was measured on the repository's own world (168 areas, every one generated). It set the defaults: 0.5 m texels, 16 rays per texel plus a tent filter, at most 128k texels per area and 8M (64 MiB) per world. Median bake 1.3 s, largest area 7.3 s (in the worker, off the main thread). The full self world is 8.8M texels, so its last areas keep the placeholder.

How to test

pnpm install
pnpm typecheck
pnpm lint
pnpm knip
pnpm test
pnpm build
pnpm --filter web dev

Then open /?seed=7, walk through the first doorway, and press Q to compare low and high.

Screenshots

Same seed (7), before (main) / after, at low and high: start view and the walk through the first doorway. Taken headless (SwiftShader).

Security review

No security-impacting changes.

🤖 Generated with Claude Code

valuecodes and others added 2 commits October 13, 2026 11:11
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 13, 2026 12:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T12:55:23.353161Z 2f12022 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment thread packages/renderer/src/bake.ts Fixed
Comment thread packages/renderer/src/bake.ts Fixed
Comment thread packages/renderer/src/bake.ts Fixed
Comment thread packages/renderer/src/bake.ts Fixed
Comment thread packages/renderer/src/bake.worker.ts Fixed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2f12022153

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/renderer/src/area-lighting.ts Outdated
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@valuecodes
valuecodes merged commit dfe4944 into main Oct 13, 2026
10 checks passed
@valuecodes
valuecodes deleted the feat/photoreal-lighting branch October 13, 2026 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants