diff --git a/research/rendering/hdr-pbr-presentation.md b/research/rendering/hdr-pbr-presentation.md new file mode 100644 index 0000000..559b147 --- /dev/null +++ b/research/rendering/hdr-pbr-presentation.md @@ -0,0 +1,127 @@ +# HDR/PBR Presentation Research + +Aquarium needs an HDR presentation path before the SDF field renderer grows real +lighting and participating media. The target is not "more bloom." The target is a +scene-linear renderer with believable dynamic range, camera exposure, optical +spill, and a display transform that preserves contrast without boiling the frame +in arcade syrup. + +## Sources + +- [ACES System overview](https://docs.acescentral.com/background/overview/) +- [Epic: How Epic Games is handling Auto Exposure in 4.25](https://www.unrealengine.com/tech-blog/how-epic-games-is-handling-auto-exposure-in-4-25?lang=en-US) +- [Unreal Engine bloom documentation](https://dev.epicgames.com/documentation/en-us/unreal-engine/bloom-in-unreal-engine?application_version=5.6) +- [Jorge Jimenez: Next Generation Post Processing in Call of Duty: Advanced Warfare](https://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare/) +- [John Hable: Filmic Tonemapping Operators](https://filmicworlds.com/blog/filmic-tonemapping-operators/) +- [John Hable: Filmic Tonemapping with Piecewise Power Curves](https://filmicworlds.com/blog/filmic-tonemapping-with-piecewise-power-curves/) +- [Hable: Uncharted 2 HDR Lighting, SIGGRAPH 2010](https://advances.realtimerendering.com/s2010/Hable-Uncharted2%28SIGGRAPH%202010%20Advanced%20RealTime%20Rendering%20Course%29.pdf) +- [Lagarde/de Rousiers: Moving Frostbite to Physically Based Rendering 3.0](https://cgvr.cs.uni-bremen.de/teaching/cg_literatur/Moving%20Frostbite%20to%20Physically%20Based%20Rendering%203.0%2C%202014%2C%20Sebastien%20Lagarde.pdf) + +## Distillation + +Modern HDR presentation is a chain, not a knob: + +1. Render lighting and emissive terms in scene-linear HDR. +2. Apply exposure in the HDR domain, preferably from a physical-camera or EV100 + model even if Aquarium initially uses manual exposure. +3. Generate bloom/glare from exposed HDR color before tonemapping. +4. Composite bloom back into exposed scene-linear color with low intensity and + broad support. +5. Apply a display transform or filmic tonemap with toe and shoulder. +6. Convert to the swapchain/display encoding only at the end. + +The important production lesson is that bloom is not a thresholded special +effect for "pixels above 1." In a high-dynamic-range PBR scene, broad low-gain +scatter can apply to the whole image while only genuinely bright energy becomes +visibly luminous. Threshold bloom is the cheap costume version; it cuts out the +low-level optical veil and encourages artists to overdrive emissive values until +the frame looks diseased. + +ACES-style and filmic transforms are useful because they give highlights a +shoulder and shadows a toe. Aquarium's current tiny ACES approximation is a +reasonable placeholder, but it is not a color-management system, not a look +authoring surface, and not enough to make the scene feel HDR by itself. + +## Aquarium Gate Plan + +### Gate HDR-A: Explicit Exposure + +Add an exposure scalar in `AquariumFrame`, initially manual and persisted through +CultCache later. + +Start simple: + +- `exposedColor = sceneLinearColor * exposure` +- default exposure chosen so Self is bright but not pinned white across its + whole disc +- debug mode for log luminance or EV bands + +Avoid auto exposure until the scene has enough stable luminance content. A +volumetric/SDF scene with huge black regions and a giant Self emitter will make +naive histogram adaptation twitch like a bad witness. + +### Gate HDR-B: Bloom Pyramid + +Add a pre-tonemap bloom pass: + +- source: exposed HDR scene color +- no hard threshold at first +- downsample pyramid with firefly-safe weighted averages +- upsample with small tent filters and per-level radius +- composite with low intensity into exposed scene color before tonemap + +This follows the Jimenez production shape: pyramidal bloom/veil for stability +and robustness, not a single huge blur taped over bright pixels. + +### Gate HDR-C: Display Transform + +Keep the current ACES approximation only as `DisplayTransform.AcesFit`. + +Add an explicit display-transform function boundary: + +- ACES fit for default +- Hable/filmic curve as an alternate debug/look path +- later: LUT-based transform if Aquarium needs an authored look + +Do not bury exposure, bloom, and tonemapping in one shader lump. The whole point +is to keep the light transport legible before volumetrics arrive and start +lying convincingly. + +### Gate HDR-D: HDR Debug Views + +Add debug views before tuning: + +- scene-linear luminance +- exposed luminance +- bloom contribution +- tonemapped final +- over-range / clipped highlight mask + +If Self, planets, Grid, and later clouds cannot be inspected in each stage, the +pipeline will become a little shrine to superstition. Burn the shrine early. + +## Rules For Aquarium + +- Bloom happens before tonemapping. +- Bloom spreads existing energy; it does not invent light. +- Prefer broad low-intensity bloom/veil over hard-threshold glow. +- Keep overlay text out of HDR and bloom unless it becomes a diegetic scene + surface. +- Do not tune emissive values against SDR final output alone. Inspect linear and + exposed luminance. +- Volumetrics must feed and be fed by the same exposure/display path as solids. +- If the frame needs "more HDR," first check exposure, display shoulder, and + source radiance before turning up bloom. + +## Immediate Recommendation + +Before the field renderer: + +1. Add explicit exposure constants. +2. Split resolve into exposed HDR color and final display transform. +3. Add a bloom pyramid between exposure and tonemap. +4. Add debug views for luminance and bloom contribution. + +This gives SDF solids/clouds a real presentation pipe to land in. Otherwise the +field renderer will arrive carrying gorgeous radiance values into a cramped SDR +mail slot, and everyone will pretend the answer is blur radius. It is not. diff --git a/state/evidence.jsonl b/state/evidence.jsonl index ad44fbd..ab3e8ce 100644 --- a/state/evidence.jsonl +++ b/state/evidence.jsonl @@ -38,3 +38,4 @@ {"area":"renderer/debug","lesson":"Temporal debug modes now expose the resolver's control data directly. Modes 5 and 6 show current temporal control channels and current field identity, so Grid support, reactive strength, medium opacity, and field ownership can be inspected without inferring them from final color or history artifacts.","files":["src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl","src/Aquarium.Engine/Render/D3D11Renderer.cs","src/Aquarium.Engine/Render/DirectWriteOverlay.cs","src/Aquarium.Engine/AquariumHost.cs","src/Aquarium.Engine/Platform/Win32Window.cs","src/Aquarium.Engine.Contracts/Input/InputState.cs","docs/tsr-inspired-taa-spec.md","docs/hlsl-renderer.md","state/memory.json","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx","Shader hot reload applied after Grid reactive channel fix","Mode 5 screenshot showed stale full-Grid reactive red; Grid reactive now zero and support remains coverage"],"ts":"2026-05-09"} {"area":"renderer/debug","lesson":"Temporal control coverage now distinguishes empty background from stable surfaces. Background pixels default coverage to zero, opaque body hits write coverage 1, and Grid hits write line/support coverage; mode 5 should therefore show black empty background rather than green covered history everywhere.","files":["src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl","state/memory.json","state/scratch.md"],"verification":["Shader hot reload applied with no stderr after control coverage fix"],"ts":"2026-05-09"} {"area":"renderer/taa","lesson":"Gate 3M cuts temporal color history out of final presentation while projection jitter is disabled. The resolver still writes history, metadata, control, age, and weight for debug/future volumetrics, but mode 0 now presents current-frame color after analytic Grid reconstruction instead of letting stale opaque-surface history ghost the frame.","files":["src/Aquarium.Engine/Render/Shaders/Aquarium.hlsl","docs/hlsl-renderer.md","docs/tsr-inspired-taa-spec.md","state/memory.json","state/scratch.md"],"verification":["dotnet build Aquarium.Engine.slnx","Shader hot reload applied with no stderr after Gate 3M cut"],"ts":"2026-05-09"} +{"area":"renderer/hdr","lesson":"Modern HDR/PBR presentation should be built as scene-linear lighting, explicit exposure, pre-tonemap bloom/veil, and an explicit display transform. Aquarium should avoid thresholded 2000s bloom; broad low-intensity bloom should spread existing HDR energy and be inspected with luminance/bloom debug views before SDF volumetrics land.","files":["research/rendering/hdr-pbr-presentation.md","state/map.yaml","state/memory.json","state/scratch.md"],"verification":["research pass over ACES, Unreal exposure/bloom docs, Jimenez COD AW post-processing, Hable filmic tonemapping, and Frostbite PBR notes"],"ts":"2026-05-09"} diff --git a/state/map.yaml b/state/map.yaml index 2bae57f..30d54c9 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -35,6 +35,7 @@ current_model: volumetrics_research: research/volumetrics/synthesis.md recent_volumetrics_and_gpu_sdf: research/volumetrics/recent-volumetrics-and-gpu-sdf.md volumetrics_transcript_addendum: research/volumetrics/transcript-addendum.md + hdr_pbr_presentation: research/rendering/hdr-pbr-presentation.md invariants: - The camera target is the Grid center on the global XY plane. @@ -64,6 +65,7 @@ renderer_state: - Add volumetrics as an explicit renderer-owned field pass, starting from Wronski/Hillaire-style frustum volume lighting with Self as the first emitter. - Evolve solids and clouds toward one SDF field registry with material and medium regimes. - Extend TSR-inspired temporal resolve with general animated-field velocity, richer reactive masks, and true volumetric history. + - Add explicit exposure, pre-tonemap bloom/veil, and display-transform debug views before the SDF field renderer. - Move Grid gradients into the Grid target for cheaper terrain normals. - Rebuild lighting as an Aquarium-owned field before adding richer fog. - Add diegetic labels and object-local menus after the renderer and text contracts are stable. @@ -76,6 +78,7 @@ next_actions: - Use research/volumetrics/recent-volumetrics-and-gpu-sdf.md before designing GPU SDF, cloud traversal, learned field storage, or radiance caching. - Check research/volumetrics/transcript-addendum.md before relying on slide decks as evidence; video transcripts can change the renderer lesson. - Follow docs/sdf-field-renderer-plan.md when adding SDF solids, SDF clouds, or hybrid field objects. + - Follow research/rendering/hdr-pbr-presentation.md before changing HDR exposure, bloom, tonemapping, or display transforms. - Follow docs/tsr-inspired-taa-spec.md when changing jitter, history, stochastic coverage, or temporal rejection. - Promote runtime knobs into typed CultCache documents. - Port only proven synth concepts into C# when audio returns; keep external prototypes as references, not engine baggage. diff --git a/state/memory.json b/state/memory.json index 948a496..9e5c3cd 100644 --- a/state/memory.json +++ b/state/memory.json @@ -36,6 +36,7 @@ "Lighting must be diegetic by default. Self is the initial emitter; later light should come from Aquarium-owned fields and transport, not ambient convenience fill.", "If surfaces read brighter than Self, the light story is broken. Diagnose source terms, texture contents, bloom order, and tonemapping before polishing.", "HDR bloom belongs before tonemapping and should be gentle in intensity but broad enough to spread true emissive energy.", + "HDR/PBR presentation should follow research/rendering/hdr-pbr-presentation.md: scene-linear lighting, explicit exposure, pre-tonemap bloom/veil, then a display transform. Do not reach for 2000s threshold bloom when the frame needs dynamic range.", "Future volumetric lighting should be a field sampled consistently by terrain, planets, fog, particles, and diegetic UI. Do not fake only the planet term if the scene is supposed to bounce light.", "Volumetric design must start from research/volumetrics/synthesis.md. The first pass should follow Wronski/Hillaire production shape: explicit low-resolution frustum volume, injected density/extinction/scattering, Self as first emitter, front-to-back transmittance/in-scattering integration, then consistent composition.", "For GPU SDF or newer volumetric storage, consult research/volumetrics/recent-volumetrics-and-gpu-sdf.md. The durable pattern is cascaded sparse bricks, compressed distance/occupancy, separate static/dynamic updates, toroidal partial updates, and learned fields only when runtime evaluation stays cheap and inspectable.", diff --git a/state/scratch.md b/state/scratch.md index 99de17f..3b11a4b 100644 --- a/state/scratch.md +++ b/state/scratch.md @@ -105,6 +105,10 @@ prototype integrated along the camera ray before surface composition. surfaces visibly juddered. Keep jitter disabled until opaque and Grid resolve both hide the offset. Removed the abandoned unjittered Grid retrace; Grid analytic final now uses the existing current hit while jitter is zero. +- HDR/PBR research pass: `research/rendering/hdr-pbr-presentation.md` says the + next renderer work before the SDF field renderer is explicit exposure, + pre-tonemap bloom/veil, and display-transform/luminance debug views. Avoid + threshold glow; bloom spreads energy already present in scene-linear HDR. - Dev watcher correction: live runtime reload now waits for the host stdout log to acknowledge the exact new live DLL path before declaring success. A pointer write alone is not proof. `dev-watch.ps1 -ReopenWhenClosed` reopens the last