Skip to content

[mod:justcause2] Add experimental HDR support - #658

Draft
xdzleo wants to merge 1 commit into
clshortfuse:mainfrom
xdzleo:mod/justcause2-hdr
Draft

xdzleo wants to merge 1 commit into
clshortfuse:mainfrom
xdzleo:mod/justcause2-hdr

Conversation

@xdzleo

@xdzleo xdzleo commented Sep 9, 2026

Copy link
Copy Markdown

Adds an experimental HDR10 addon for the 32-bit Steam version of Just Cause 2 using its native Direct3D 10.1 renderer. The game's scene composite and motion-blur pass previously lost highlight range at UNORM writes. FP16 resource clones and replacements before those writes preserve that range through scene processing, HUD composition, and the final PQ output.

This is a draft for technical review. The measured gameplay path works with the standalone addon, but the outstanding coverage below needs validation before this should be considered ready to merge.

Implementation

  • Adds 25 game shader replacements: 15 scene-composite variants, the final motion-blur pass, exposure statistics, and eight packed-motion producers.
  • Preserves the native composite's exposure, grading, depth of field, grain, tint, and vignette. An sRGB decode of the native sqrt output is stored before the game's scene copy so subsequent filtering retains its original decoded domain.
  • Upgrades full-resolution RGBA8 TYPELESS and UNORM render targets, including both MSAA resolve endpoints, to FP16 clones. Packed-motion data and exposure statistics retain their original bounds separately from HDR scene color.
  • Uses a thin SM4 SwapChainPass proxy for SDR or HDR10/PQ output. Encoding follows the last successful DXGI color-space transition. A game-local D3D10 state block restores game bindings and releases captured references each present for resize compatibility.
  • Defaults to SDR and neutral exposure, contrast, and saturation. HDR10 is opt-in; Vanilla scene range bypasses optional grading, and Preset Off restores SDR/Vanilla and neutral settings. Game and UI white are independent.
  • Limits source changes to src/games/justcause2; metadata selects experimental, d3d10, and x86. No generated binaries, dumps, system DLLs, shared infrastructure, or workflow changes are included.

Validation

  • cmake --build --preset clang-x86-debug --target justcause2 passed during development. cmake --build --preset clang-x86-release --target justcause2 passed against upstream cd32113a98608e63027d40910cfe296a14dfe228, including all 25 replacements and both proxy shaders. Existing shared-header deprecation warnings remain.
  • Metadata passes the repository JSON schema. C++ and shared HLSL helpers pass the repository clang-format configuration.
  • Original shader decompilation checks passed; the main composite and final motion pass were live-tested as baseline replacements before HDR edits. Six patched packed-motion producers were observed across 353 draws in a captured frame. Compilation does not establish runtime coverage of every variant.
  • Native D3D10.1 gameplay at 2560 x 1440 with 8x MSAA confirmed FP16 scene and resolve resources. At a configured peak of 1000 nits, an HDR scene readback reached RGB 9.539 with 30,295 pixels above 1. The composed FP16 output also retained values above 1; the final RGB10A2 backbuffer was PQ encoded with DXGI confirming PQ/BT.2020. Analyzed textures contained no NaN/Inf pixels. These readbacks came from separate presents, not one synchronized frozen frame.
  • SDR post-composite readback and packed-motion data remained bounded to 0-1. SDR/HDR switching, swapchain recreation, and restart into HDR gameplay were tested with only the game addon enabled and DevKit disabled. Runtime observations used Debug builds before the three upstream commits following 66f4a40; the current Release build has not been gameplay-tested.

Manual verification: build the justcause2 target, deploy renodx-justcause2.addon32 beside JustCause2.exe with the 32-bit ReShade addon loader, and keep DevKit disabled for standalone checks. With Windows HDR enabled, select HDR10 in RenoDX Just Cause 2, compare SDR and Vanilla, test white/peak controls, and exercise MSAA, resize, restart, and gameplay. The game README documents the tested loader workaround and its limitations.

Outstanding validation

  • Fixed-scene SDR reference comparisons are still needed: FP16 upgrades remain active in SDR, and original 8-bit quantization is not reproduced exactly.
  • The validated output graph includes 0x5046D433 after the composite. Motion-blur-off or other settings that might bypass that pass have not been proven; all presentation paths must reach the intended output domain.
  • Broader coverage of composite variants, fast motion, antialiasing modes, menus, video, and UI brightness is pending.
  • The local installation required a copy of its own system SysWOW64/d3d10.dll beside the executable to avoid an early exit with ReShade's delayed hook. No Microsoft DLL is included. More installations should confirm loader compatibility.
  • Physical display calibration and sustained highlight behavior remain unmeasured. A 2000-nit setting was reviewed mathematically, not measured on a 2000-nit display.

This contribution was developed with AI assistance, using local shader captures, compilation, and in-game validation. The measurements above support the tested path and do not claim pixel-identical SDR or complete game coverage.

RenoDX review checklist (self-review)
Item Result
Scoped files and coherent commit Pass
Actionable review comments Pass — remaining evidence is identified above
Vanilla appearance at default settings Needs comment — fixed-scene SDR comparison and quantization coverage remain pending
Preset Off and Vanilla semantics Pass
No inverse tonemapping of the final SDR frame Pass
ToneMapPass / UpgradeToneMap signal contract N/A — neither is used
Linear input to the highlight shoulder Pass
LUT domain and reconstruction N/A — spatial grade, no identified LUT
HDR range preserved before final output Pass for the captured path
Thin SwapChainPass over a proven intermediate Needs comment — prove final motion-pass coverage under alternative settings
HDR10/PQ with SDR/HDR toggle Pass

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.

1 participant