Skip to content

feat: HDR rendering#1692

Merged
davo0411 merged 223 commits into
community-shaders:devfrom
davo0411:hdr-output
Apr 8, 2026
Merged

feat: HDR rendering#1692
davo0411 merged 223 commits into
community-shaders:devfrom
davo0411:hdr-output

Conversation

@davo0411
Copy link
Copy Markdown
Collaborator

@davo0411 davo0411 commented Jan 11, 2026

image

game renders entirely in HDR, with tonemapping at the end to clamp to SDR & gamma convert or output HDR

Summary by CodeRabbit

  • New Features
    • Added HDR Display support for compatible monitors with automatic detection and configuration.
    • Integrated advanced color management including HDR tonemapping, color space conversion, and dynamic UI brightness scaling for enhanced visual fidelity on HDR-capable displays.
    • Improved environment map rendering and color grading capabilities for HDR output.

davo0411 and others added 18 commits January 10, 2026 17:42
* build: bump eastl to 3.27.01 (community-shaders#1673)

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>

* fix(grass collision): ignore hkpListShape (community-shaders#1661)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* chore(upscaling): update SDKs (community-shaders#1684)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* chore(terrain shadows): modernize (community-shaders#1678)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat: add user wiki link to readme (community-shaders#1689)

* feat(LLF): add debug overlay in llf visualiser (community-shaders#1666)

* feat: linear lighting (community-shaders#1359)

Co-authored-by: jiayev <jiayev@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat: weather and imagespace editor (community-shaders#1630)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* fix(ui): load previously selected theme on startup (community-shaders#1664)

---------

Co-authored-by: Alan Tse <alandtse@users.noreply.github.com>
Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Co-authored-by: doodlum <15017472+doodlum@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: jiayev <l936249247@hotmail.com>
Co-authored-by: jiayev <jiayev@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 11, 2026

No actionable suggestions for changed features.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 11, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This pull request introduces comprehensive HDR (High Dynamic Range) display support. It adds a new HDRDisplay feature that detects HDR-capable monitors and manages HDR rendering through enhanced shader utilities for color-space conversions and tonemapping. The implementation includes framebuffer redirection for UI compositing, compute shaders for HDR output and brightness handling, swap-chain format upgrades (R10G10B10A2 for HDR10), and integration with the upscaling system to preserve HDR data during post-processing.

Changes

Cohort / File(s) Summary
HDR Feature System
src/Features/HDR.h, src/Features/HDR.cpp, src/Features/HDRDisplay.h, src/Features/HDRDisplay.cpp, features/HDR Display/Shaders/Features/HDRDisplay.ini
New singleton HDR controller with resource management, UI rendering redirection, swap-chain color-space handling, and HDR metadata updates. HDRDisplay feature wrapper delegates operations to HDR singleton with settings serialization.
Feature Registration
src/Feature.cpp, src/Globals.h, src/Globals.cpp
Added HDRDisplay to global feature list and imported HDRDisplay header for feature discovery.
Shader Color Infrastructure
package/Shaders/Common/Color.hlsli, package/Shaders/Common/DisplayMapping.hlsli
Extensive color-space conversion matrices and functions (BT.709↔BT.2020, OKLab, PQ encoding/decoding), gamma/linear helpers, DICE tonemapping suite with luminance compression, and cross-space color restoration utilities.
HDR Rendering Pipeline
package/Shaders/ISHDR.hlsl, package/Shaders/Effect.hlsl, package/Shaders/Lighting.hlsl, package/Shaders/ISIBLensFlare.hlsl
Dual HDR/SDR rendering paths with conditional gamma conversions guarded by HDR_OUTPUT. HDR preserves values >1.0 with DICE tonemapping; SDR clamps to 0–1. Includes auto-exposure and replaced saturate clamps with max(0, ...) for HDR compatibility.
Shader Constant Buffers
package/Shaders/Common/SharedData.hlsli, src/State.h, src/State.cpp
Added HDRData float4 field to SharedData cbuffer with enableHDR, paperWhite, peakNits parameters; populated from HDR singleton settings during state updates.
HDR Compute Shaders
features/HDR Display/Shaders/HDRDisplay/HDROutputCS.hlsl, features/HDR Display/Shaders/HDRDisplay/UIBrightnessCS.hlsl
New compute shaders for compositing UI onto PQ-encoded HDR scene with optional SDR fallback and dithering; separate shader for frame-generation UI brightness scaling with color-space conversion.
Swap Chain & Device Integration
src/Hooks.cpp, src/Features/DynamicCubemaps.cpp
Upgraded swap-chain format to R10G10B10A2_UNORM (HDR10) in D3D11/D3D12 paths; switched environment map format from R11G11B10_FLOAT to R16G16B16A16_FLOAT for HDR; conditionally binds HDR UI texture and applies HDR post-processing before present.
Upscaling System Integration
src/Features/Upscaling.cpp, src/Features/Upscaling/DX12SwapChain.h, src/Features/Upscaling/DX12SwapChain.cpp, src/Features/Upscaling/FidelityFX.h, src/Features/Upscaling/FidelityFX.cpp
DX12SwapChain gained SetColorSpace(bool) to apply HDR10 or sRGB color spaces with metadata; FidelityFX::Present signature extended with a_isHDR parameter for frame-generation HDR state tracking (peakNits, isHDRActive, needsReset atomics); Upscaling framebuffer redirection around ISHDR preserves HDR values.
UI & Menu Integration
src/Menu/BackgroundBlur.cpp
Skips background blur when HDR output is active to prevent incorrect compositing during HDR rendering.

Sequence Diagram(s)

sequenceDiagram
    participant Game as Game Engine
    participant HDRMgr as HDR Singleton
    participant D3D as D3D11/D3D12
    participant ShaderPipe as Shader Pipeline
    participant UIComp as UI Compositor
    participant Present as Swap Chain Present

    Game->>HDRMgr: DetectHDRDisplay()
    HDRMgr->>D3D: Query display capabilities (DXGI)
    D3D-->>HDRMgr: isHDRMonitor state
    
    Game->>HDRMgr: SetupResources()
    HDRMgr->>D3D: Create HDR textures (float16, R10G10B10A2)
    HDRMgr->>D3D: Upgrade swap chain to HDR10
    D3D-->>HDRMgr: Textures & swap chain ready

    Game->>Game: Render scene
    Game->>ShaderPipe: ISHDR shader (HDR enabled)
    ShaderPipe->>ShaderPipe: Branch HDR vs SDR path
    Note over ShaderPipe: HDR: Preserve >1.0, DICE tonemap<br/>SDR: Clamp to 0–1
    ShaderPipe-->>Game: Scene rendered

    Game->>HDRMgr: BeginUIRendering()
    HDRMgr->>D3D: Redirect RTV to HDR UI texture

    Game->>Game: Render UI (ImGui)
    
    Game->>HDRMgr: EndUIRendering()
    HDRMgr->>D3D: Restore RTV

    HDRMgr->>UIComp: HDROutputCS (composite shader)
    UIComp->>UIComp: Convert UI sRGB → BT.2020 → PQ
    UIComp->>UIComp: Blend UI with scene PQ
    UIComp-->>HDRMgr: Composited HDR output

    Game->>Present: IDXGISwapChain::Present()
    Present->>Present: ApplyHDR() if HDR ready
    Present->>D3D: Copy HDR output to swap chain
    D3D-->>Present: HDR frame presented
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested reviewers

  • doodlum
  • jiayev

Poem

🐰 Hop through realms of light unbounded,
Where colors dance past one, wide-sighted,
PQ-encoded dreams, HDR-rounded,
Ten thousand nits, the display ignited!
UI blooms in space newly minted,
The rabbit's eyes glow—bright, glinted.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.05% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: HDR rendering' clearly and directly summarizes the main change: adding comprehensive HDR (High Dynamic Range) rendering support throughout the codebase, including shaders, color-space conversions, tone mapping, and display handling.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@davo0411 davo0411 merged commit e9190e6 into community-shaders:dev Apr 8, 2026
15 checks passed
This was referenced May 9, 2026
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.

5 participants