Skip to content

Give the rooms PBR surfaces, AgX tone mapping and a post-processing chain - #38

Merged
valuecodes merged 5 commits into
mainfrom
feat/photoreal-materials
Oct 13, 2026
Merged

valuecodes merged 5 commits into
mainfrom
feat/photoreal-materials

Conversation

@valuecodes

Copy link
Copy Markdown
Owner

What

  • Part 1/2 of Toward a photorealistic Code Backrooms: materials, tone mapping and post-processing, so the rooms stop reading as flat-shaded boxes.
  • The wallpaper, carpet and ceiling tile are seeded, periodic height fields (height-field.ts) that give each surface a colour, normal and occlusion-roughness map; nothing is fetched, the maps tile without a seam, and all nine generate in ~190 ms (512², 2 mm per texel).
  • Both Canvases share one AgX colour pipeline at exposure 1.15: the renderer tone-maps at low; at high a composer (n8ao ambient occlusion at half resolution, bloom off the fixtures, grain, vignette, lens fringing) tone-maps last. The haze past the fog is a sphere around the camera so it is tone-mapped like the walls at both levels. Measured headlessly on seed 7: high is ~4 % darker than low (the AO and vignette) and returns to the same values after toggling; high costs ~1.8× low on software GL.
  • Q toggles the quality (kept in localStorage); the HUD shows it. n8ao ships no types, so the renderer declares the module and the app's tsconfig lists it under types.

How to test

pnpm typecheck
pnpm lint
pnpm knip
pnpm test
pnpm build
pnpm --filter web dev # open ?seed=7&rooms=12, press Q to compare levels

Security review

No security-impacting changes.

🤖 Generated with Claude Code

valuecodes and others added 3 commits October 13, 2026 09:36
The wallpaper, carpet and ceiling tile are seeded, periodic height fields
that give each surface a colour, normal and occlusion-roughness map, so the
rooms have relief without fetching any assets. Both Canvases now share one
AgX colour pipeline at one exposure: the renderer tone-maps at the low
quality, and at high a post-processing chain (n8ao ambient occlusion,
bloom off the fixtures, grain, vignette, lens fringing) tone-maps last. The
haze past the fog is a sphere around the camera, tone-mapped like the
walls at either quality. Q toggles the quality, kept in localStorage.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The lattice noise precomputes its per-axis cells and blends, the blur runs
with a running sum, and the maps are 512 texels across (2 mm on a 1 m tile):
the nine maps now take about 190 ms instead of 7 s. Finer wallpaper grain
and sparse, shallow ceiling fissures keep the stripe and diamond motif and
the tile readable; exposure 1.15 brings AgX level with the previous look.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Set AgX on the renderer only at the low quality: the composer, a child,
turns tone mapping off before the parent effect ran, so re-applying AgX
there mapped the frame twice. Build the n8ao pass once per Canvas and keep
it across quality changes, as Pass.dispose does not reach its fullscreen
objects and every rebuild leaked them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings October 13, 2026 06:54

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-13T07:03:15.471424Z 141abaa 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.

@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: 141abaa2c8

ℹ️ 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/effects.tsx Outdated
Comment thread packages/renderer/src/effects.tsx Outdated
valuecodes and others added 2 commits October 13, 2026 10:03
On a real screen the grain read as noise and the post chain cost a frame on
top of the frame, so the default is now low (the old single pass with the
new materials) and high is opted into with Q: its grain drops from 3.5 % to
1 % and the ambient occlusion takes 8 samples and 4 denoise taps.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Set the renderer's tone mapping in a layout effect, before the World's
passive shader precompile, so it warms the variants the first frame uses:
AgX at low, none at high where the composer maps. Multisample the
composer's off-screen buffer (4 samples): the Canvas's own antialiasing
does not reach it, so high rendered aliased edges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@valuecodes
valuecodes merged commit 2a4c383 into main Oct 13, 2026
10 checks passed
@valuecodes
valuecodes deleted the feat/photoreal-materials branch October 13, 2026 07:20
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.

2 participants