Skip to content

render: add framebuffer post effects (bloom, blur, colour grade) - #5143

Merged
jakildev merged 4 commits into
masterfrom
claude/render-post-effects
Nov 17, 2026
Merged

jakildev merged 4 commits into
masterfrom
claude/render-post-effects

Conversation

@jakildev

Copy link
Copy Markdown
Owner

Summary

Adds FRAMEBUFFER_POST_EFFECTS: a thresholded bloom, a separable Gaussian blur and a colour grade over the image presented for the main framebuffer, each switched independently and all off by default. A creation drives them per frame from IRPrefab::PostEffects::setState or IRRender.setPostEffects{...}; the screen blit and --auto-record both present the result. It runs after the glitch pass, and with every switch off it encodes no GPU work.

The GLSL shaders are unverified on OpenGL. Only the Metal side was run (macOS host). Contract: docs/design/post-effects.md.

Screenshots

No visual change to existing shots: 21 of 21 pairs identical, IRShapeDebug.

post_effects_all (new, --post-effects-test all): blur radius 2, screened bloom and a warm grade together.

post_effects_all

Clip recorded by --auto-record with the same effects on:
full clip (mp4)

4 more new shots: control, blur, bloom, grade

post_effects_off (control)

post_effects_off

post_effects_blur (radius 6)

post_effects_blur

post_effects_bloom (threshold 0.55, 5 levels, additive)

post_effects_bloom

post_effects_grade

post_effects_grade

Test plan

All on macOS Metal, Apple M4 Max, at this head unless a line says otherwise.

  • fleet-run IrredenEngineTest: 4056 tests passed, 0 failed.
  • fleet-run IRShapeDebug --auto-screenshot 10 on origin/master and on this branch: 28 of 28 captures byte-identical (cmp).
  • fleet-run IRShapeDebug --post-effects-test standard-off --auto-screenshot 10: 28 of 28 captures byte-identical to the default run.
  • --post-effects-test blur and grade: [post-effects-probe] cpuTwin mismatchedTexels=0 cpuMaxDelta=0 over 927048 texels.
  • --post-effects-test bloom: darker=0 brighter=609544; off: published=false frameDraws=0.
  • python3 scripts/render-verify.py --target IRShapeDebug --no-build (at b510942, before two behaviour-neutral line moves): the five new post_effects_* rows pass at 100% match, max delta 0. The run exits 1 on 24 rows that are red on master too (see notes). At this head the five captures still equal the committed references byte for byte.
  • fleet-run IRShapeDebug --post-effects-test all --auto-record 180 --config-preset scripts/fleet/clip-preset.lua: the recorded frames carry the blur, bloom and grade (clip above).
  • python3 scripts/shader_parity_audit.py: clean, 167 glsl and 155 metal files.
  • cmake -DPROJECT_ROOT=$PWD -P cmake/run_header_checks_standalone.cmake: header, save-inventory and GLSL reserved-word checks pass.
Reviewer notes

Notes for reviewer

🤖 Generated with Claude Code

jakildev and others added 4 commits November 17, 2026 10:52
FRAMEBUFFER_POST_EFFECTS draws a thresholded bloom, a separable Gaussian
blur and a colour grade over the image presented for the main
framebuffer, into a twin output image the screen blit and the recorder
then present. One singleton, C_PostEffectsState, holds every parameter;
IRPrefab::PostEffects::setState and IRRender.setPostEffects{...} drive
it, and each effect is switched independently and off by default. With
every switch off the pass encodes no GPU work.

The pass runs after FRAMEBUFFER_GLITCH and reads its output on a tick
that pass drew one. IRPrefab::PresentedFrame::mainColor() names the
image actually presented, so FRAMEBUFFER_TO_SCREEN and VideoManager no
longer ask the glitch pass directly.

Every texture read is a whole-texel fetch, so the Metal and GLSL
shaders and the CPU twin in post_effects_math.hpp read the same texels.
Only the Metal side has been run; the GLSL side is unverified on
OpenGL.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…bouring edits

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@jakildev jakildev added fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend labels Nov 17, 2026
@github-actions

Copy link
Copy Markdown

Perf gate

Head host slug: linux-x86_64-epyc-7763-64-unknown

perf comparison: 973cca4 → 4b9196b-ci

baseline: /home/runner/work/_temp/perf-baseline/history/linux-x86_64-epyc-7763-64-unknown/973cca473801b9af350f107b73a985f8ddd02e13
head: /home/runner/work/IrredenEngine/IrredenEngine/save_files/perf/4b9196b38-ci

host calibration

  • host: linux-x86_64-epyc-7763-64-unknown (matches baseline)
  • ref_ms: head 104.31 vs baseline 103.27 (load_factor 1.01×)
  • calibration target: 50.00 ms (informational)
  • baseline capture: perf-baseline@973cca473 (branch tip); master c614ba3d6, finished 2026-11-17T06:35:14Z, 0.6 d before the head run, ref_ms 103.27
  • weighting: raw (class-matched capture; load_factor 1.01×; no calibration-scaling entry)
  • attribution: no measured master improvement between capture master c614ba3d6 and merge base a914699df (10 commits)

thresholds: regress ≥ 10%, improve ≥ 5%

voxel cull effectiveness

cell ratio (base→head) avg visible total avg feeder
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 1024 → 1024 0 → 0
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.598 → 0.598 (+0.0pp) 156630 → 156630 1024 → 1024 0 → 0
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 1.000 → 1.000 (+0.0pp) 262144 → 262144 1024 → 1024 0 → 0
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 0.975 → 0.975 (+0.0pp) 255592 → 255592 1024 → 1024 0 → 0

frame timing (ms)

cell avg p99
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 526.84 → 542.69 (+3.0%) 1768.15 → 1937.53 (+9.6%)
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 1233.37 → 1272.02 (+3.1%) 2496.24 → 2564.94 (+2.8%)
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 682.69 → 711.66 (+4.2%) 12631.16 → 13217.28 (+4.6%)
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 1785.49 → 1803.65 (+1.0%) 3022.52 → 3063.48 (+1.4%)

GPU frame timing (ms; separate from stage samples)

cell envelope (base→head) buffer spans (base→head) coverage (base→head)
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 unavailable → unavailable unavailable → unavailable unavailable → unavailable

GPU stage timing (avg ms per sampled invocation)

cell canvasClear voxelCompact voxelStage1 voxelCardinalElect voxelStage2 voxelSunFaces textToTrixel buildLightOcclusionGrid computeVoxelAO bakeSunShadowMap computeSunShadow computeLightVolume lightingToTrixel fogToTrixel trixelToFb resolvePerAxisScreenDepth fbToScreen
target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1 22.04→22.36 66.78→65.36 55.77→54.81 1.00→1.28 ⚠ 56.03→55.07 95.13→95.86 — 0.00→0.00 2.86→2.74 27.58→27.14 12.14→12.37 23.90→23.12 4.13→3.95 1.35→1.28 0.20→0.18 ↓ — 8.03→8.06
target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1 21.53→22.81 319.05→319.16 261.00→260.43 4.07→4.17 237.12→236.60 143.76→146.25 — 0.00→0.00 2.47→2.44 46.01→45.50 11.73→10.74 ↓ 21.08→20.06 9.03→8.68 1.74→1.48 ↓ 0.18→0.16 ↓ — 7.57→7.52
target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1 19.89→20.39 78.80→79.09 61.84→62.13 13.10→13.22 49.55→49.02 87.90→89.25 1.15→1.14 0.00→0.00 16.66→16.60 71.88→72.19 11.08→11.04 57.96→58.61 8.19→8.10 1.87→1.83 0.17→0.15 ↓ 0.00→0.00 9.08→9.00
target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1 20.51→21.57 520.75→522.24 425.16→422.80 6.33→6.38 372.12→372.34 153.55→153.81 1.19→1.14 0.00→0.00 2.50→2.44 61.27→59.44 12.28→12.42 21.73→21.92 7.15→7.32 1.74→1.60 ↓ 0.17→0.16 ↓ 0.00→0.00 7.54→7.47

top CPU systems by avg ms (head)

target=IRLuaPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 297.961 → 296.528 (-0.5%)
RENDER ComputeLightVolume 35.515 → 34.996 (-1.5%)
RENDER ComputeSunShadow 19.866 → 19.696 (-0.9%)
RENDER CanvasToFramebuffer 17.575 → 17.533 (-0.2%)
RENDER BakeSunShadowMap 10.404 → 10.046 (-3.4%)
UPDATE FogRevealEval 4.318 → 6.321 (+46.4%) ⚠
UPDATE PropagateTransform 4.466 → 4.710 (+5.5%)
RENDER ComputeVoxelAO 4.413 → 4.244 (-3.8%)

target=IRLuaPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 981.501 → 984.359 (+0.3%)
RENDER ComputeSunShadow 39.727 → 39.142 (-1.5%)
RENDER ComputeLightVolume 32.335 → 30.294 (-6.3%) ↓
RENDER CanvasToFramebuffer 16.231 → 16.470 (+1.5%)
RENDER ComputeVoxelAO 10.820 → 10.542 (-2.6%)
RENDER BakeSunShadowMap 8.796 → 8.890 (+1.1%)
RENDER LightingToTrixel 9.229 → 8.886 (-3.7%)
UPDATE PropagateTransform 4.292 → 6.791 (+58.2%) ⚠

target=IRPerfGrid,zoom=1,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 328.031 → 337.595 (+2.9%)
RENDER ComputeSunShadow 64.391 → 64.837 (+0.7%)
RENDER LightingToTrixel 36.422 → 36.867 (+1.2%)
RENDER ComputeLightVolume 33.720 → 33.862 (+0.4%)
RENDER BakeSunShadowMap 22.888 → 22.689 (-0.9%)
RENDER CanvasToFramebuffer 17.895 → 18.021 (+0.7%)
RENDER FogToTrixel 7.296 → 7.170 (-1.7%)
UPDATE PropagateTransform 6.223 → 6.472 (+4.0%)

target=IRPerfGrid,zoom=4,sub_mode=full,sub_base=1

pipeline system avg ms (base→head)
RENDER SingleVoxelToCanvasFirst 1495.587 → 1495.907 (+0.0%)
RENDER ComputeSunShadow 54.602 → 53.105 (-2.7%)
RENDER ComputeLightVolume 33.594 → 33.787 (+0.6%)
RENDER CanvasToFramebuffer 16.024 → 16.320 (+1.8%)
RENDER BakeSunShadowMap 8.899 → 8.702 (-2.2%)
RENDER ComputeVoxelAO 8.698 → 8.603 (-1.1%)
RENDER LightingToTrixel 7.329 → 7.488 (+2.2%)
UPDATE PropagateTransform 6.286 → 6.366 (+1.3%)

@jakildev jakildev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review — render: add framebuffer post effects (bloom, blur, colour grade)

Verdict: approve

The publication/lifetime/order contracts and backend-mirrored math are coherent; I found no merge-blocking defect.

Checked

  • Reviewed the complete PR thread and detached head a6cf01571699ea155c77c91890bf9b4a43626313, including the implementation, Metal/GLSL shader twins, Lua surface, tests, fixtures, and design contract.
  • fleet-build --detach --target IrredenEngineTest completed successfully.
  • fleet-run IrredenEngineTest --gtest_filter='*PostEffects*:*SystemNameEnumBound' passed all 36 selected tests.
  • git diff --check origin/master...HEAD passed.
  • PR-relevant CI is green, including render harness, shader parity, performance, format, and header checks. fleet-tests is red on the unrelated claim-race harness flake also reproduced on a recent master run; this diff does not touch fleet scripts. The Linux build was still running at review time.
  • The OpenGL shaders remain unverified on this macOS-authored change and are routed to Windows smoke debt.

🤖 Reviewed by Codex GPT-5 (review-pr skill)

Opus recheck not required (reviewed at opus class).

@jakildev jakildev added fleet:approved Fleet reviewer approved — ready for human merge fleet:needs-windows-smoke PR needs windows-debug build + smoke-run validation and removed fleet:reviewing-mac-pool-4 labels Nov 17, 2026
@evin-mac-claude-app evin-mac-claude-app Bot added the fleet:checks-red Info only: approved PR whose head has a failed check of its own; reconcile R12 adds and removes it label Nov 17, 2026
@jakildev
jakildev merged commit 44955ae into master Nov 17, 2026
13 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fleet:approved Fleet reviewer approved — ready for human merge fleet:author-claude Implementation last authored by Claude; route review to Codex fleet:authored-on-macos PR was authored and smoke-tested on macOS Metal backend fleet:checks-red Info only: approved PR whose head has a failed check of its own; reconcile R12 adds and removes it fleet:needs-windows-smoke PR needs windows-debug build + smoke-run validation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant