[GH-ISSUE #3472] HDR lighting: light above paper white (a plan for discussion) #982

Closed
opened 2026-11-02 15:43:19 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @senjinthedragon on GitHub (Oct 29, 2026).
Original GitHub issue: https://github.com/horizon-rust/horizon/issues/3472

🤖 Written by Senjin's AI agent (Claude Code), posted by Senjin.

Part of #1441. A plan for the next step of HDR, for discussion before any code: light itself above paper white,
not only light sources.

Where HDR is today

The world is drawn exactly as in SDR, in vanilla's gamma space, onto the 8-bit frame. A last pass (hdr.wgsl)
decodes it to light at Paper White and lifts the pixels of light sources (torches, lava, glowstone, the sun) into the
headroom up to Peak Brightness, by the kind of light (#2705). Everything that isn't a light source stays at SDR
brightness: a sunlit meadow at noon is as bright as a torch-lit room, because the lightmap stops at 1.0 and the
frame can't hold more.

What "HDR lighting" would add

  • Sunlight brighter than shade. Faces turned to the sun at noon above paper white; the shaded side, and
    everything at dusk, at or below it.
  • Light near its source. A wall right next to a torch or lava brighter than paper white, falling off to the
    vanilla level a few blocks away.
  • Eyes that adapt. Walking out of a cave into daylight, the world is blinding for a moment and then settles;
    walking in, it settles the other way.
  • Light sources that are light, written into the frame at their HDR brightness instead of lifted afterwards, so
    fog, water and stained glass in front of them dim them correctly.

Why in the client, and not left to shader packs

Some of this sounds like what players expect from shader packs on vanilla. But on vanilla, a shader pack alone
can't do HDR: Iris and OptiFine present an SDR frame (Iris's Colorspace setting, Rec.2020 and the like, widens the
gamut, not the brightness). HDR there takes a separate mod that adds the HDR output to Iris, plus shader packs
patched to write HDR for it. That says the same thing from the other side: what makes HDR work lives in the
client, not in a pack:

  • The output itself: the HDR swapchain, its metadata, and what the display and desktop report (Paper White and
    Peak Brightness on Auto, #3461). A pack can't know the player's display.
  • Light sources: which blocks give light and how strongly comes from the game's block data and the tiers (#2705),
    which a pack doesn't see.
  • A default for everyone: most players never install a pack. With HDR Lighting off by default and the vanilla look
    as its calibration point, it's an option for HDR displays, not a different game.

Packs stay in charge where they want to be: the HDR output proposed in #3125 would let a pack take over the light
completely, and the built-in lighting is what a pack starts from or replaces (see Shader packs below).

Rules it keeps

  1. HDR off: nothing changes. Same pipelines, same 8-bit frame, same screenshots (the parity harnesses keep
    checking that).
  2. HDR on, HDR Lighting off: what #2705 and the PRs after it do now. HDR Lighting is a new switch on
    Graphics: HDR, off by default, because it changes the vanilla look (docs/design-system.md).
  3. The dark stays dark. Darkness is gameplay in Minecraft: mobs spawn where it's dark, and players read light
    levels by eye. Adaptation may dim a bright scene, but it never brightens a cave or a night above vanilla.
  4. Vanilla is the calibration point. A scene with no extra light (no sun, no light sources near) looks the same
    with HDR Lighting on as with it off.

The plan, in small PRs

Each step is its own PR, well under 500 lines, and each one can ship alone.

  1. A float world target while HDR Lighting is on. The world renders into Rgba16Float instead of the 8-bit
    frame. The pipelines don't change: they keep vanilla's gamma-space math (blending, fog, translucency), only now
    values above 1.0 survive, and the HDR pass decodes them the same way (gamma 2.2, extended above 1). With no value
    above 1 yet, the picture is identical: that's the proof for this step. Cost: the world target doubles from 4 to
    8 bytes a pixel.
  2. Light sources write their own brightness. The tier, mask and unlit-texel lift (#2705 and the relative masks)
    move from the HDR pass into the mark writers (terrain, entities, particles, sun and moon), which then write the
    HDR value straight into the frame. The alpha mark retires in this mode. This is also where LabPBR emission
    maps would plug in (the alpha of a pack's _s.png, per texel, ahead of the measured masks); Horizon doesn't
    read them yet, and that would be its own PR after the relative masks.
  3. Block light above paper white. The lightmap without its final clamp for block light: the top levels (about
    12 to 15) extend past 1.0 along vanilla's own curve, scaled by a share of the headroom as the tiers are. Below
    that, the lightmap is vanilla's to the bit.
  4. Exposure. A small pass measures the world's average brightness (log average over a downsampled copy, the
    same kind of GPU pass as hdr_stats) and adapts over a second or two, faster into the light than out of it.
    The exposure only scales the world, never the HUD (UI Brightness stays what it is), and per rule 3 it only ever
    lowers.
  5. Sunlight. The sky term of the lightmap gets a sun factor above 1 on faces turned to the sun (from the
    celestial angle the sky already uses), shaped by the time of day and weather: rain and dusk bring it back to
    vanilla. Exposure (step 4) keeps a noon meadow from being uniformly blinding.
  6. Tone mapping to the display. Instead of today's cap at Peak Brightness, a BT.2390 EETF (the curve the black
    level already uses at the bottom) rolls highlights off into the display's peak, so the brightest sunlit faces
    don't clip flat.

Later, separately: sun shadows. Without them, step 5 lights every sun-facing face, under an overhang too, so it
stays modest. Horizon's shader API plans a shadow stage, and #1180 has ray-traced sun shadows working; either could
feed a shadowed/unshadowed bit into step 5. Bloom could come after step 2, also off by default.

Shader packs

While a shader pack's post or material stage runs, HDR Lighting stays off (the HDR pass falls back to today's lift),
until packs can opt in through the HDR output proposed in #3125. The shader API's planned lighting stage is
the natural home for steps 3 and 5: Horizon's HDR lighting could be the built-in lighting stage, which a pack
replaces. Packs in the shaders/ format: off.

Testing

  • HDR off and HDR Lighting off: the existing screenshots and harnesses, unchanged.
  • HDR Lighting on: I test on Plasma (KWin, a QD-OLED). It needs testers on Windows, and on macOS once Horizon
    presents HDR there.
  • Each step's PR shows before/after HDR screenshots (16-bit PNG, #3152).

Questions for the Team

  1. Is a new switch on Graphics: HDR, off by default, the right shape?
  2. Should steps 1 to 4 also run on SDR displays later (exposure and tone mapping down to SDR)? That changes the
    vanilla look more, so I'd leave SDR out for now.
  3. Steps 3 and 5 as Horizon's built-in lighting stage of the shader API, or kept apart from it until that stage
    exists?
  4. Sun shadows: wait for the shadow stage or #1180, or is per-face sunlight (step 5) fine to start with?

The roadmap's hdr item ("later") predates the HDR work; I can update its text in a PR if that's welcome.

🤖 Generated with Claude Code

Originally created by @senjinthedragon on GitHub (Oct 29, 2026). Original GitHub issue: https://github.com/horizon-rust/horizon/issues/3472 > 🤖 Written by Senjin's AI agent (Claude Code), posted by Senjin. Part of #1441. A plan for the next step of HDR, for discussion before any code: **light itself above paper white**, not only light sources. ## Where HDR is today The world is drawn exactly as in SDR, in vanilla's gamma space, onto the 8-bit frame. A last pass (`hdr.wgsl`) decodes it to light at Paper White and lifts the pixels of light sources (torches, lava, glowstone, the sun) into the headroom up to Peak Brightness, by the kind of light (#2705). Everything that isn't a light source stays at SDR brightness: a sunlit meadow at noon is as bright as a torch-lit room, because the lightmap stops at 1.0 and the frame can't hold more. ## What "HDR lighting" would add - **Sunlight brighter than shade.** Faces turned to the sun at noon above paper white; the shaded side, and everything at dusk, at or below it. - **Light near its source.** A wall right next to a torch or lava brighter than paper white, falling off to the vanilla level a few blocks away. - **Eyes that adapt.** Walking out of a cave into daylight, the world is blinding for a moment and then settles; walking in, it settles the other way. - **Light sources that are light,** written into the frame at their HDR brightness instead of lifted afterwards, so fog, water and stained glass in front of them dim them correctly. ## Why in the client, and not left to shader packs Some of this sounds like what players expect from shader packs on vanilla. But on vanilla, a shader pack alone can't do HDR: Iris and OptiFine present an SDR frame (Iris's Colorspace setting, Rec.2020 and the like, widens the gamut, not the brightness). HDR there takes a separate mod that adds the HDR output to Iris, plus shader packs patched to write HDR for it. That says the same thing from the other side: what makes HDR work lives in the client, not in a pack: - The output itself: the HDR swapchain, its metadata, and what the display and desktop report (Paper White and Peak Brightness on Auto, #3461). A pack can't know the player's display. - Light sources: which blocks give light and how strongly comes from the game's block data and the tiers (#2705), which a pack doesn't see. - A default for everyone: most players never install a pack. With HDR Lighting off by default and the vanilla look as its calibration point, it's an option for HDR displays, not a different game. Packs stay in charge where they want to be: the HDR output proposed in #3125 would let a pack take over the light completely, and the built-in lighting is what a pack starts from or replaces (see Shader packs below). ## Rules it keeps 1. **HDR off: nothing changes.** Same pipelines, same 8-bit frame, same screenshots (the parity harnesses keep checking that). 2. **HDR on, HDR Lighting off: what #2705 and the PRs after it do now.** HDR Lighting is a new switch on Graphics: HDR, **off by default**, because it changes the vanilla look (docs/design-system.md). 3. **The dark stays dark.** Darkness is gameplay in Minecraft: mobs spawn where it's dark, and players read light levels by eye. Adaptation may dim a bright scene, but it never brightens a cave or a night above vanilla. 4. **Vanilla is the calibration point.** A scene with no extra light (no sun, no light sources near) looks the same with HDR Lighting on as with it off. ## The plan, in small PRs Each step is its own PR, well under 500 lines, and each one can ship alone. 1. **A float world target while HDR Lighting is on.** The world renders into `Rgba16Float` instead of the 8-bit frame. The pipelines don't change: they keep vanilla's gamma-space math (blending, fog, translucency), only now values above 1.0 survive, and the HDR pass decodes them the same way (gamma 2.2, extended above 1). With no value above 1 yet, the picture is identical: that's the proof for this step. Cost: the world target doubles from 4 to 8 bytes a pixel. 2. **Light sources write their own brightness.** The tier, mask and unlit-texel lift (#2705 and the relative masks) move from the HDR pass into the mark writers (terrain, entities, particles, sun and moon), which then write the HDR value straight into the frame. The alpha mark retires in this mode. This is also where LabPBR emission maps would plug in (the alpha of a pack's `_s.png`, per texel, ahead of the measured masks); Horizon doesn't read them yet, and that would be its own PR after the relative masks. 3. **Block light above paper white.** The lightmap without its final clamp for block light: the top levels (about 12 to 15) extend past 1.0 along vanilla's own curve, scaled by a share of the headroom as the tiers are. Below that, the lightmap is vanilla's to the bit. 4. **Exposure.** A small pass measures the world's average brightness (log average over a downsampled copy, the same kind of GPU pass as `hdr_stats`) and adapts over a second or two, faster into the light than out of it. The exposure only scales the world, never the HUD (UI Brightness stays what it is), and per rule 3 it only ever lowers. 5. **Sunlight.** The sky term of the lightmap gets a sun factor above 1 on faces turned to the sun (from the celestial angle the sky already uses), shaped by the time of day and weather: rain and dusk bring it back to vanilla. Exposure (step 4) keeps a noon meadow from being uniformly blinding. 6. **Tone mapping to the display.** Instead of today's cap at Peak Brightness, a BT.2390 EETF (the curve the black level already uses at the bottom) rolls highlights off into the display's peak, so the brightest sunlit faces don't clip flat. **Later, separately:** sun shadows. Without them, step 5 lights every sun-facing face, under an overhang too, so it stays modest. Horizon's shader API plans a shadow stage, and #1180 has ray-traced sun shadows working; either could feed a shadowed/unshadowed bit into step 5. Bloom could come after step 2, also off by default. ## Shader packs While a shader pack's post or material stage runs, HDR Lighting stays off (the HDR pass falls back to today's lift), until packs can opt in through the HDR output proposed in #3125. The shader API's planned **lighting stage** is the natural home for steps 3 and 5: Horizon's HDR lighting could be the built-in lighting stage, which a pack replaces. Packs in the `shaders/` format: off. ## Testing - HDR off and HDR Lighting off: the existing screenshots and harnesses, unchanged. - HDR Lighting on: I test on Plasma (KWin, a QD-OLED). It needs testers on Windows, and on macOS once Horizon presents HDR there. - Each step's PR shows before/after HDR screenshots (16-bit PNG, #3152). ## Questions for the Team 1. Is a new switch on Graphics: HDR, off by default, the right shape? 2. Should steps 1 to 4 also run on SDR displays later (exposure and tone mapping down to SDR)? That changes the vanilla look more, so I'd leave SDR out for now. 3. Steps 3 and 5 as Horizon's built-in lighting stage of the shader API, or kept apart from it until that stage exists? 4. Sun shadows: wait for the shadow stage or #1180, or is per-face sunlight (step 5) fine to start with? The roadmap's `hdr` item ("later") predates the HDR work; I can update its text in a PR if that's welcome. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@senjinthedragon commented on GitHub (Nov 2, 2026):

🤖 Agent: Done, so closing this. Light above paper white is in #6671, with follow-ups in #6870 (water), #6900 (stars and clouds), #6531 (conduit, warden, far terrain) and #6669 (fog). Where it went differently from the plan above:

  • No Rgba16Float world target: the frame's alpha between 0.76 and 1 carries how much light a surface gets to the last pass, which works out as the lightmap going past 1 without new targets.
  • No separate HDR Lighting switch: HDR, already off by default, does it, and HORIZON_HDR_LIGHTING=0 turns it off to compare.
  • Sun-facing light and a roll-off into the peak are in. Exposure isn't: one strength looked right everywhere it was tried.
  • Shadows and a lighting stage for shader packs aren't in; lighting turns itself off while a pack's post or material stage runs.

Details in docs/graphics.md.

<!-- gh-comment-id:6574713339 --> @senjinthedragon commented on GitHub (Nov 2, 2026): 🤖 Agent: Done, so closing this. Light above paper white is in #6671, with follow-ups in #6870 (water), #6900 (stars and clouds), #6531 (conduit, warden, far terrain) and #6669 (fog). Where it went differently from the plan above: - No Rgba16Float world target: the frame's alpha between 0.76 and 1 carries how much light a surface gets to the last pass, which works out as the lightmap going past 1 without new targets. - No separate HDR Lighting switch: HDR, already off by default, does it, and HORIZON_HDR_LIGHTING=0 turns it off to compare. - Sun-facing light and a roll-off into the peak are in. Exposure isn't: one strength looked right everywhere it was tried. - Shadows and a lighting stage for shader packs aren't in; lighting turns itself off while a pack's post or material stage runs. Details in docs/graphics.md.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#982
No description provided.