Skip to content

chore(hdr): rewrite hdr sun#2090

Merged
doodlum merged 28 commits into
community-shaders:devfrom
davo0411:hdr-sun-fixes
May 6, 2026
Merged

chore(hdr): rewrite hdr sun#2090
doodlum merged 28 commits into
community-shaders:devfrom
davo0411:hdr-sun-fixes

Conversation

@davo0411
Copy link
Copy Markdown
Collaborator

@davo0411 davo0411 commented Apr 11, 2026

fixes for HDR sun shape code, and clamps volumetric lighting to 0-1 to prevent huge blowout with some weather mods, like Astralite which was unusable.
Sets sun brightness in menus to 100 nits to match sdr, instead of the weird 0.58x brightness I had before.

205DBF~1 20156B~1 209B90~1 20997F~1

Summary by CodeRabbit

  • Bug Fixes

    • Clamped volumetric lighting at multiple stages to prevent over‑brightening and ensure stable output.
  • New Features

    • Consolidated HDR sun handling into a unified HDR sun routine providing controllable sun boosting with radial falloff and cloud‑aware modulation.
    • Extended HDR output handling to sky rendering so HDR sun behavior applies consistently when HDR is active.
  • Documentation

    • Clarified comment describing HDR menu/scene sun scaling behavior.

Copilot AI review requested due to automatic review settings April 11, 2026 09:14
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 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

Clamps volumetric lighting at multiple stages and refactors HDR sun handling: Sky.hlsl now delegates HDR sun gain computation to a new HDRSun.hlsli (guarded by HDR_OUTPUT); HDR define applicability and a SharedData comment were updated.

Changes

Cohort / File(s) Summary
Volumetric lighting
package/Shaders/ISApplyVolumetricLighting.hlsl
Introduce explicit clamping to 1.0 at sampled VL, intensity-scaled VL, noise-adjusted intermediate (now saturate(noiseGrad + vl - kVLThresholdBias)), and final temporal/non-temporal outputs; add kVLThresholdBias = 1.0/128.0.
Sky / HDR sun integration
package/Shaders/Sky.hlsl, features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli
Remove large inlined HDR-only sun branch from Sky.hlsl; when HDR_OUTPUT include new HDRSun.hlsli and use HDRSun::GetHdrSunGain(...) and HDRSun::IsHdrSunActive() to apply HDR sun gain and gate cloud-shadow/noise logic. Replace prior manual HDR scaling/dither logic with HDRSun API call.
HDR define & comment
src/Features/HDRDisplay.h
Treat RE::BSShader::Type::Sky as requiring HDR_OUTPUT in HDRDisplay::HasShaderDefine and update comment for SharedData::HDRData.w to indicate it stores the ISHDR menu/scene path (affects HDRSun scaling toward menu nits).

Sequence Diagram(s)

sequenceDiagram
  participant Sky as Sky.hlsl
  participant HDR as HDRSun.hlsli
  participant Shared as SharedData
  participant Tex as sunTex
  Sky->>Shared: read HDRData (x,z,w)
  Sky->>HDR: call GetHdrSunGain(texCoord, baseColor, sunTex, samp, alpha)
  HDR->>Tex: sample coarse/fine mip(sunTex)
  HDR->>Shared: use HDRData values to compute boost/weight
  HDR-->>Sky: return hdrGain
  Sky->>Sky: apply hdrGain to baseColor and gate glare/cloud-shadow via IsHdrSunActive()
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • doodlum
  • alandtse

Poem

🐇✨ I hopped through pixels, nudged the sun's bright tune,
I capped the mist so fog won't sing too soon,
Moved gleam to HDR's tidy little file,
Kept clouds and noise in one organized pile,
A rabbit's hop — the shaders hum in tune.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% 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 PR title 'chore(hdr): rewrite hdr sun' accurately reflects the primary change: a rewrite of HDR sun handling logic in the shader. It is concise, specific, and directly describes the main objective.

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

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

Automated formatting by clang-format, prettier, and other hooks.
See https://pre-commit.ci for details.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts HDR rendering behavior to prevent excessive brightness, specifically by refining the HDR sun glare/disc shaping logic and clamping volumetric lighting output to a 0–1 range to avoid blowouts with certain weather mods.

Changes:

  • Refines HDR sun scaling by adding radial/alpha/luminance gating so HDR gain is concentrated toward the sun core instead of the entire quad.
  • Clamps volumetric lighting sampling, adjusted value, and final output to 0–1 to prevent extreme brightness spikes.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
package/Shaders/Sky.hlsl Updates HDR sun glare/disc scaling with radial and alpha/luminance-based tapering to reduce HDR blowout.
package/Shaders/ISApplyVolumetricLighting.hlsl Clamps volumetric lighting sample and output to [0, 1] to prevent overbright volumetric contribution.

Comment thread package/Shaders/Sky.hlsl Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 11, 2026

No actionable suggestions for changed features.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
package/Shaders/Sky.hlsl (1)

231-236: Consider naming the new tuning constants.

This block adds several coupled knobs (1.85, 0.32, 0.62, 0.22, 0.88, 0.94, etc.). Hoisting them into named static const values would make the next round of visual tuning much safer.

Also applies to: 247-251, 282-293

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package/Shaders/Sky.hlsl` around lines 231 - 236, This change introduces
several magic-number "tuning knobs" in the Sky shader (e.g., the constants
1.41421356 and 1.85 used with sunUvRadial, sunRadialR, and sunRadialHdr inside
the TEX block), so hoist those literals into descriptive static const float
names (for example: SUN_UV_CENTER_SCALE, SUN_RADIAL_POWER, etc.) and replace the
inline numbers in the expressions that compute sunUvRadial, sunRadialR,
sunRadialHdr; do the same for the other magic numbers referenced in the nearby
blocks (lines around 247-251 and 282-293) so each numeric tuning value has a
single named constant defined near the top of the shader and reused where needed
to simplify future visual tuning.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@package/Shaders/ISApplyVolumetricLighting.hlsl`:
- Around line 48-49: The current code clamps vlSample immediately (vlSample =
min(...,1.0)) which squashes values >1.0 before applying the intensity scale;
instead sample the texture without the min (use VLTex.SampleLevel(VLSampler,
float3(input.TexCoord, repartition), 0).x directly into vlSample) and then apply
the intensity scale and clamp on vl (vl = min(g_IntensityX_TemporalY.x *
vlSample, 1.0)); update the code that sets vlSample and vl (variables vlSample,
vl, and the VLTex.SampleLevel call) so the clamp happens after scaling, leaving
the later caps at lines 53/86/88 intact.

---

Nitpick comments:
In `@package/Shaders/Sky.hlsl`:
- Around line 231-236: This change introduces several magic-number "tuning
knobs" in the Sky shader (e.g., the constants 1.41421356 and 1.85 used with
sunUvRadial, sunRadialR, and sunRadialHdr inside the TEX block), so hoist those
literals into descriptive static const float names (for example:
SUN_UV_CENTER_SCALE, SUN_RADIAL_POWER, etc.) and replace the inline numbers in
the expressions that compute sunUvRadial, sunRadialR, sunRadialHdr; do the same
for the other magic numbers referenced in the nearby blocks (lines around
247-251 and 282-293) so each numeric tuning value has a single named constant
defined near the top of the shader and reused where needed to simplify future
visual tuning.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1519f0fb-6dd9-4ca9-9d52-29936c510206

📥 Commits

Reviewing files that changed from the base of the PR and between f0a752f and 3602e0c.

📒 Files selected for processing (2)
  • package/Shaders/ISApplyVolumetricLighting.hlsl
  • package/Shaders/Sky.hlsl

Comment thread package/Shaders/ISApplyVolumetricLighting.hlsl Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
package/Shaders/Sky.hlsl (3)

220-230: PR metadata polish: normalize title casing and link issue.

Suggested title: fix(hdr): clamp volumetric lighting and sun tuning
If this resolves a tracked bug, add a keyword line in the PR body (e.g., Fixes #<issue-id>).

As per coding guidelines: "Conventional Commit Titles... Format: type(scope): description" and "Issue References... Suggest adding appropriate GitHub keywords."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package/Shaders/Sky.hlsl` around lines 220 - 230, Update the PR metadata:
change the commit/PR title to follow Conventional Commits format (e.g.,
"fix(hdr): clamp volumetric lighting and sun tuning") and, if this change fixes
a tracked bug, add an issue reference line in the PR body such as "Fixes
#<issue-id>"; this is purely a metadata change and does not modify code like
SharedData::HDRData, SUN_HDR_MENU_TARGET_NITS, hdrScale, ENABLE_LL, or the HDR
sun scaling logic in Sky.hlsl.

222-236: Consider centralizing new sun-tuning literals.

The added constants/exponents are understandable, but grouping them as named static const values would make iteration and regression tracking easier.

Also applies to: 248-253, 283-292

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package/Shaders/Sky.hlsl` around lines 222 - 236, Centralize the new literal
tuning values by introducing descriptive static const names and replacing magic
numbers in the Sun/HDR calculations: replace SUN_REF_PAPER_WHITE_NITS,
SUN_HDR_MENU_TARGET_NITS, the exponent 1.85 used in computing sunRadialHdr, the
radial scale 1.41421356, the gamma reciprocal 2.2 (used in rcp(2.2)), and the
small threshold 1e-3 with named constants; declare these static const floats
near the top of the shader or the SharedData/HDR block so hdrScale,
hdrSunMenuMul, sunRadialR and sunRadialHdr computations (and the related blocks
around SUN_REF_PAPER_WHITE_NITS, hdrSunMenuMul, hdrScale, and the TEX branch
computing sunRadialHdr) reference those constants instead of raw literals for
easier tuning and regression tracking.

296-297: Consider quantizing screen coordinates for consistency with other IGN uses in the codebase.

At Line 296, while using input.Position.xy directly is valid, other shaders in the codebase (e.g., StereoSyncCS.hlsl) use integer pixel/thread IDs for the IGN hash. For consistency and to ensure pixel-perfect stability with temporal effects, consider quantizing:

- float ign = frac(52.9829189 * frac(dot(input.Position.xy, float2(0.06711056, 0.00583715))));
+ float2 ignPixel = floor(input.Position.xy);
+ float ign = frac(52.9829189 * frac(dot(ignPixel, float2(0.06711056, 0.00583715))));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package/Shaders/Sky.hlsl` around lines 296 - 297, The IGN calculation uses
input.Position.xy directly; to match other shaders (e.g., the IGN hash in
StereoSyncCS) and ensure pixel-stable results, quantize the screen coordinates
before hashing: replace the direct use of input.Position.xy in the dot() that
feeds frac(...) with integer/rounded pixel coordinates (e.g., floor or round of
input.Position.xy or SV_Position.xy) so ign is computed from the quantized pixel
position; keep the rest of the expression (the constants, frac chain, and use of
discScale) unchanged and ensure the variable name ign is preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@package/Shaders/Sky.hlsl`:
- Around line 220-230: Update the PR metadata: change the commit/PR title to
follow Conventional Commits format (e.g., "fix(hdr): clamp volumetric lighting
and sun tuning") and, if this change fixes a tracked bug, add an issue reference
line in the PR body such as "Fixes #<issue-id>"; this is purely a metadata
change and does not modify code like SharedData::HDRData,
SUN_HDR_MENU_TARGET_NITS, hdrScale, ENABLE_LL, or the HDR sun scaling logic in
Sky.hlsl.
- Around line 222-236: Centralize the new literal tuning values by introducing
descriptive static const names and replacing magic numbers in the Sun/HDR
calculations: replace SUN_REF_PAPER_WHITE_NITS, SUN_HDR_MENU_TARGET_NITS, the
exponent 1.85 used in computing sunRadialHdr, the radial scale 1.41421356, the
gamma reciprocal 2.2 (used in rcp(2.2)), and the small threshold 1e-3 with named
constants; declare these static const floats near the top of the shader or the
SharedData/HDR block so hdrScale, hdrSunMenuMul, sunRadialR and sunRadialHdr
computations (and the related blocks around SUN_REF_PAPER_WHITE_NITS,
hdrSunMenuMul, hdrScale, and the TEX branch computing sunRadialHdr) reference
those constants instead of raw literals for easier tuning and regression
tracking.
- Around line 296-297: The IGN calculation uses input.Position.xy directly; to
match other shaders (e.g., the IGN hash in StereoSyncCS) and ensure pixel-stable
results, quantize the screen coordinates before hashing: replace the direct use
of input.Position.xy in the dot() that feeds frac(...) with integer/rounded
pixel coordinates (e.g., floor or round of input.Position.xy or SV_Position.xy)
so ign is computed from the quantized pixel position; keep the rest of the
expression (the constants, frac chain, and use of discScale) unchanged and
ensure the variable name ign is preserved.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0a7a210c-0907-4899-80cc-959d7bd607a6

📥 Commits

Reviewing files that changed from the base of the PR and between 3602e0c and befbb88.

📒 Files selected for processing (2)
  • package/Shaders/Sky.hlsl
  • src/Features/HDRDisplay.h
✅ Files skipped from review due to trivial changes (1)
  • src/Features/HDRDisplay.h

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 11, 2026

✅ A pre-release build is available for this PR:
Download

Comment thread package/Shaders/Sky.hlsl Outdated
Comment thread package/Shaders/Sky.hlsl Outdated
Comment thread package/Shaders/Sky.hlsl Outdated
Comment thread package/Shaders/Sky.hlsl Outdated
Comment thread package/Shaders/Sky.hlsl Outdated
Comment thread package/Shaders/Sky.hlsl Outdated
Comment thread package/Shaders/Sky.hlsl Outdated
Comment thread package/Shaders/Sky.hlsl Outdated
@davo0411 davo0411 requested a review from doodlum April 12, 2026 09:43
@davo0411 davo0411 changed the title fix(HDR): clamp vol lighting to 1, sun tweaks fix(HDR): clamp vol lighting, rewrite hdr sun Apr 12, 2026
@doodlum
Copy link
Copy Markdown
Collaborator

doodlum commented Apr 16, 2026

@coderabbitai analyse this pull request and be as mean as possible to @davo0411

@davo0411
Copy link
Copy Markdown
Collaborator Author

image

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 16, 2026

🧩 Analysis chain

The PR description images show:

  • PR description image 1: A bright midday sky with a centered sun. Top-left overlay block titled “HDR Analysis (HDR10)” shows per-channel stats (labels like L_avg and L_max and horizontal meters). Bottom-right a nit-scale histogram labeled roughly 0.25 → 10000 nits, showing a broad highlight mound with a fat orange/red cap at high nits corresponding to the sun. Scene elements: Whiterun skyline, rocks, a bare tree; subtle sun rays and bloom.
  • PR description image 2: Same framing; the sun disc/bloom is tighter. The HDR graph’s sun highlight collapses into a narrow, much taller spike (red tip) at high nits; mid-tones remain similar.
  • PR description image 3: In‑game radial menu with “CHARACTER” selected; options like TALENTS, SKILLS, ITEMS, INVENTORY, WORLD, JOURNAL, QUESTS; top-right shows “Sundas, 6:00 PM, 17th of Last Seed, 4E 201.” HDR Analysis overlay present; histogram energy centered in mid-luminance with no extreme high-nit spike.

@doodlum All right, steel-toed review boots on. Here’s the blunt take aimed squarely at the code (not the human):

  • Volumetric clamp carpet-bombing: If you’re clamping the sample, the intensity-scaled value, the noise-adjusted value, and then again on the temporal output, that’s four saturates chasing the same scalar. Pick the last meaningful stage (pre-blend and final out), prove why the others aren’t dead weight, or delete them. Every extra saturate is another place to flatten gradients and murder subtle fog variation frame-to-frame.
  • Space hygiene: I need to see explicit proof that every clamp is in your working linear/irradiance space, not after any gamma-ish transform. If any path clamps post-gamma, that’s a visual crime scene. Show me where baseColor/VL are defined and converted.
  • Temporal path: Clamping before and after blending can bias persistence. If previousVl is already in [0,1], clamping adjustedVl before the lerp plus clamping the lerp result is redundant and reduces contrast in low-VL weathers. Keep one saturate on the final output unless you can demonstrate temporal ringing without the pre-blend clamp.
  • HDR sun rework: Moving to HDRSun.hlsli is good housekeeping, but the function signature is a kitchen sink. You’re taking position, worldPosition, vertexColor, two samplers, alphaPostScale, baseColor inout, yyy inout, then sprinkling dither/cloud shadows inside. That’s a leaky abstraction: Sky.hlsl now depends on HDRSun doing half the material graph’s job. Either:
    • Keep HDRSun strictly to gain shaping on baseColor and return a scalar gain, or
    • Embrace the refactor fully and move all cloud-shadow and dither concerns out of Sky’s remaining branches to avoid duplicated modulation and permutation spaghetti.
  • Menu/scene 100‑nit target: If you’re steering sun toward 100 nits when SharedData::HDRData.w indicates menu/pause, confirm that w only flips for ISHDR menu path. If any in-world photo mode or fade-to-black also toggles it, you’ll undercut creative highlights during transitions. Also, cap the boost path with a monotonic curve that approaches the target without discontinuities at the toggle boundary.
  • 203‑nit paper white scaling: If you’re deriving “peak-to-boost” as peak/203, make sure the exponent doesn’t overfit to 1k–1.5k‑nit displays. On 4k‑nit sets your pow(maxBoost, weight) will rocket unless maxBoost is bounded by actual mastering metadata. If you’re using SharedData::HDRData.z as peak, clamp maxBoost to a sane upper (e.g., displayPeak / paperWhite but softened with a shoulder).
  • Radial/alpha gating: Squaring alpha to weight gain is fine for the disc, but you also add a coarse-mip “quell” from sunTex. Without exposure/tonemap awareness, that can flip with mip transitions and generate popping on camera motion. Add hysteresis or a smoothstep on mip-derived quells; or prefilter once at a fixed mip level.
  • DITHER path divergence: You’ve got different finishing behavior under DITHER vs non-DITHER. That’s asking for micro‑desync between build permutations. Reconcile outputs so both end with identical color except for the actual dithering injection.
  • Cloud shadow double-multiply risk: You say you modulate baseColor.xyz and baseColor.w inside HDRSun when CLOUD_SHADOWS is defined. Verify Sky.hlsl doesn’t also multiply those again later in the TEX path. If it does, you’ve halved solar energy twice and that’s why your “smaller sun is after.”
  • HDR_OUTPUT define expansion: Forcing HDR_OUTPUT for Sky via HasShaderDefine means every Sky technique compiles an HDR path. Confirm the non-HDR renderers and VR don’t accidentally get HDR uniforms bound null and branch on uninitialized SharedData::HDRData. If the VR rule is “skip unknown imagespaces by returning false,” mirror that spirit here and early-out HDRSun when the buffer isn’t populated.
  • Naming/API: HDRSun::IsHdrSunActive() + ApplyHdrSunToBaseColor() reads like two knobs controlling the same door. Make Apply… return a bool “modified” and drop IsHdrSunActive(), or inline the active test inside Apply and have it no-op.

If you want this merged without me gnawing the chair leg:

  • Trim the redundant clamps.
  • Prove color-space correctness with a comment at each clamp site.
  • Make HDRSun.hlsli a focused, side‑effect‑light module: one input struct, one output color, one optional scalar for glare reuse — no sampler side gigs if Sky is also sampling.
  • Add compile‑time asserts or static comments on the meaning/range of SharedData::HDRData.{x,z,w}, including units (nits vs normalized).
  • Add a toggle or cvar to fade the HDR sun boost strength for testing, else tuning will be paint-by-guess.

References: The PR description claims these scope changes and shows the before/after HDR graphs that match the “narrow spike” result; my critiques above are exactly about how you achieve that without collateral damage. (github.com)


🏁 Script executed:

#!/bin/bash
set -euo pipefail

PR_NUMBER=2090

echo "== Git status =="
git rev-parse --is-inside-work-tree && git branch --show-current || true
git remote -v || true

# Try to get base/head via gh. Fall back to 'dev' if unavailable.
BASE_REF="dev"
HEAD_REF="$(git rev-parse --abbrev-ref HEAD || echo 'HEAD')"
if command -v gh >/dev/null 2>&1; then
  echo "== Fetching PR metadata via gh =="
  gh pr view "$PR_NUMBER" --json baseRefName,headRefName,files,url 2>/dev/null | tee pr_meta.json || true
  BASE_REF="$(jq -r '.baseRefName // "dev"' pr_meta.json 2>/dev/null || echo dev)"
  HEAD_REF_FROM_GH="$(jq -r '.headRefName // empty' pr_meta.json 2>/dev/null || true)"
  if [[ -n "${HEAD_REF_FROM_GH:-}" ]]; then HEAD_REF="$HEAD_REF_FROM_GH"; fi
fi

echo "Base ref: $BASE_REF"
echo "Head ref: $HEAD_REF"

# Ensure base is fetched for diff
git fetch origin "$BASE_REF":"refs/remotes/origin/$BASE_REF" >/dev/null 2>&1 || true
MERGE_BASE="$(git merge-base HEAD "origin/$BASE_REF" 2>/dev/null || echo "")"

DIFF_RANGE="HEAD"
if [[ -n "$MERGE_BASE" ]]; then
  DIFF_RANGE="$MERGE_BASE...HEAD"
fi
echo "Diff range: $DIFF_RANGE"

echo "== Changed files =="
git diff --name-only $DIFF_RANGE | tee changed_files.txt

# Show focused diffs for suspected files; print context
for f in package/Shaders/ISApplyVolumetricLighting.hlsl package/Shaders/Sky.hlsl "features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli" src/Features/HDRDisplay.h; do
  if [[ -f "$f" ]]; then
    echo "---- PATCH: $f ----"
    git diff -U6 $DIFF_RANGE -- "$f" || true
    echo
  fi
done

# If new file exists, print its contents (trim long lines kept)
if [[ -f "features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli" ]]; then
  echo "==== CONTENT: HDRSun.hlsli (head) ===="
  nl -ba "features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli" | sed -n '1,260p'
fi

echo "== Cross-references =="
# Find all uses of the new HDRSun API and HDR_OUTPUT in Sky shaders
rg -nP -C3 $'HDRSun::|ApplyHdrSunToBaseColor|IsHdrSunActive|#\\s*define\\s*HDR_OUTPUT|SharedData::HDRData\\.[wzxy]' -- \
  || true

# Check other volumetric lighting clamps/temporal logic
rg -nP -C4 $'ISApplyVolumetricLighting|temporalContribution|previousVl|saturate\\(|clamp\\(|VL\\b' package/Shaders | sed -n '1,400p' || true

# Find where menu/pause nits are defined
rg -nP -C3 $'Menu|Pause|kMenuSunNits|100\\s*nits|203' features src package | sed -n '1,300p' || true

Length of output: 403


The PR description images show:

  • PR description image 1: Midday sky with a very bright, soft-edged sun and subtle rays. Top-left “HDR Analysis (HDR10)” block shows per-channel stats with L_avg/L_max bars; bottom-right histogram spans 0.25→10,000 nits with a wide orange/red highlight mound from the sun. Whiterun skyline and rocks at the bottom.
  • PR description image 2: Same scene; sun disc/bloom is tighter. HDR graph collapses the broad mound into a thin, taller high‑nit spike while mid‑tones are similar.
  • PR description image 3: Radial pause menu (“CHARACTER” selected; options like TALENTS, SKILLS, ITEMS, INVENTORY, WORLD, JOURNAL, QUESTS), top‑right “Sundas, 6:00 PM, 17th of Last Seed, 4E 201”. Histogram energy in mid‑luminance, no extreme spike.

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Compute diff range vs origin/dev =="
git fetch origin dev:refs/remotes/origin/dev >/dev/null 2>&1 || true
MERGE_BASE="$(git merge-base HEAD origin/dev || true)"
if [[ -n "${MERGE_BASE:-}" ]]; then
  DIFF_RANGE="$MERGE_BASE...HEAD"
else
  DIFF_RANGE="HEAD"
fi
echo "DIFF_RANGE=${DIFF_RANGE}"

echo
echo "== Changed files =="
git diff --name-only ${DIFF_RANGE} || true

echo
echo "== Focused diffs =="
for f in \
  "features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli" \
  "package/Shaders/ISApplyVolumetricLighting.hlsl" \
  "package/Shaders/Sky.hlsl" \
  "src/Features/HDRDisplay.h"
do
  if [[ -f "$f" ]]; then
    echo "---- DIFF: $f ----"
    git diff -U4 ${DIFF_RANGE} -- "$f" || true
    echo
  fi
done

echo "== Quick scans =="
if [[ -f "package/Shaders/ISApplyVolumetricLighting.hlsl" ]]; then
  echo "-- Clamp/temporal lines in ISApplyVolumetricLighting.hlsl --"
  rg -n -C2 $'vlSample|adjustedVl|psout\\.VL|temporalContribution|min\\(|max\\(|saturate\\(' package/Shaders/ISApplyVolumetricLighting.hlsl || true
fi

if [[ -f "package/Shaders/Sky.hlsl" ]]; then
  echo "-- HDRSun usage in Sky.hlsl --"
  rg -n -C3 $'HDRSun::|ApplyHdrSunToBaseColor|IsHdrSunActive|#\\s*include\\s*\"HDRDisplay/HDRSun.hlsli\"|CLOUD_SHADOWS|DITHER' package/Shaders/Sky.hlsl || true
fi

if [[ -f "features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli" ]]; then
  echo "-- Key constants/paths in HDRSun.hlsli --"
  rg -n -C2 $'kReferencePaperWhiteNits|kMenuSunNits|maxBoost|pow\\(|mipQuell|CloudShadows|InterleavedGradientNoise' "features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli" || true
fi

if [[ -f "src/Features/HDRDisplay.h" ]]; then
  echo "-- Define + HDRData.w comment in HDRDisplay.h --"
  rg -n -C2 $'HasShaderDefine|HDRData\\.w|kHdrMenuScene' src/Features/HDRDisplay.h || true
fi

Length of output: 10925


The PR description images show:

  • PR description image 1: Midday sky with a soft, bloomy sun. Top‑left “HDR Analysis (HDR10)” stats block with L_avg/L_max bars; bottom‑right nit histogram (0.25→10,000) shows a wide orange/red mound for the sun. Whiterun skyline/rocks/tree at the bottom.
  • PR description image 2: Same view; the sun disc and bloom are tighter. The histogram collapses into a thinner, taller high‑nit spike while mid‑tones stay similar.
  • PR description image 3: Radial menu with “CHARACTER” selected; top‑right “Sundas, 6:00 PM, 17th of Last Seed, 4E 201.” Histogram energy sits in mid‑luminance with no extreme spike.

@doodlum Buckle up. Here’s the no‑sugarcoat code review for #2090 aimed squarely at the code, not the author:

Volumetric lighting (package/Shaders/ISApplyVolumetricLighting.hlsl)

  • Redundant clamps everywhere:
    • Line 48: vlSample = min(sample, 1.0)
    • Line 49: vl = min(intensity * vlSample, 1.0)
    • Line 53: adjustedVl = min(max(0, noise + vl − 0.0078125), 1.0)
    • Line 86: psout.VL = min(lerp(...), 1.0)
    • Line 88: psout.VL = min(adjustedVl, 1.0)
      Pick your battles. Early clamps crush headroom for the thresholding at Line 53 and bias the temporal blend. Keep one saturate on the final output and optionally one at adjustedVl for safety — drop the rest unless you can show ringing without them.
  • Style/space consistency: use saturate(x) instead of min(x,1.0) and explicit max(x,0.0). It’s idiomatic HLSL and cheaper. Also clamp symmetric ranges once, not thrice.
  • Temporal bias: clamping adjustedVl before the blend plus clamping the blend result flattens fog evolution under camera motion. Unless previousVl can exit [0,1] (it shouldn’t), pre‑blend clamp is redundant.

Concrete fix sketch:

// sample + scale (preserve headroom here)
float vlSample = VLTex.SampleLevel(VLSampler, float3(input.TexCoord, repartition), 0).x;
float vl = g_IntensityX_TemporalY.x * vlSample;

// threshold, then clamp once
float adjustedVl = saturate(noiseGrad + vl - 0.0078125);

float temporalContribution = g_IntensityX_TemporalY.y * (1 - smoothstep(0, 1, min(1, 100 * abs(depth - previousDepth))));
psout.VL = saturate(lerp(adjustedVl, previousVl, temporalContribution * isValid));

Sky/HDR sun (package/Shaders/Sky.hlsl)

  • Abstraction leak: HDRSun::ApplyHdrSunToBaseColor(...) (Line 225) takes position, UVs, vertex color, world pos, tex+sampler, alphaPostScale, baseColor inout, and yyy inout. That’s not a focused “sun gain” helper; it’s a side‑effect buffet. Either:
    • Make it return a scalar gain (plus optional dither contribution) and keep Sky in control, or
    • Move all related sampling/tint/dither/cloud‑shadow logic into HDRSun and ensure Sky doesn’t repeat any of it.
      Right now you also branch on IsHdrSunActive() to avoid re‑tinting (Lines 246–251), which is a symptom of the leak.
  • Initialization risk: You pass yyy by reference before the DITHER block sets the noise path. Make sure yyy is declared/initialized before the HDRSun call in all permutations, or you’ve got UB in non‑DITHER builds.
  • Permutation guardrails: Ensure HDRSun::IsHdrSunActive() encodes both “HDR enabled” and “Permutation::ExtraFlags::IsSun”. If it only checks HDRData.x, non‑sun sky quads can get the sun boost.
  • Double cloud attenuation: Per the PR notes, HDRSun handles cloud transmittance. Sky still has CLOUD_SHADOWS handling later in some permutations. Audit for double‑multiplication; it would explain the “smaller sun after” even when highlights look tidier.

HDR intent and constants

  • Paper‑white/peak math: The old path used a 203‑nit reference and an extra menu dim. If HDRSun now drives to 100 nits in menus and “peak/203” in scene, document exact formulas and clamp max boost against SharedData::HDRData.z (display peak). On 4,000‑nit sets, pow(maxBoost, weight) can nuke tone‑mapper stability without a shoulder.
  • Menu/scene toggle (SharedData::HDRData.w): Define its states and transitions in a header comment with units. Make it monotonic and hysteretic around transitions to avoid a visible pop when the menu appears.

Safety and build matrix

  • HDR_OUTPUT define expansion to Sky: Good for feature parity, but confirm non‑HDR and VR builds early‑out harmlessly. Drawing on prior repo learning for VR fallbacks (Imagespace shaders correctly defer to vanilla when un‑RE’d), mirror the spirit here: if SharedData isn’t populated, HDRSun must be a no‑op.
  • Compile‑time sanity: Static_assert‑style comments on expected ranges for SharedData::HDRData.{x,y,z,w} will save future regressions.

Tests you owe us before merge

  • A/B captures: noon clear, overcast, sunset into menu open/close. Show per‑frame plots to prove no pop at boundary and no temporal “rubber banding.”
  • Worst‑case weather mod (you named Astralite): three scenes demonstrating VL clamp doesn’t crush fog structure at low intensity and doesn’t shimmer with motion.
  • VR/SE build compiles for Sky with HDR disabled.

Nits

  • Replace magic 0.0078125 with a named constant (it’s 1/128; say why).
  • Prefer saturate() everywhere you meant [0,1].
  • Document units: nits vs normalized [0,1] for every variable in HDRSun.hlsli and HDRDisplay.h.

If you clean up the clamp spam, tighten the HDRSun API, and prove the non‑HDR/VR paths are inert, I’m out of things to throw. Until then, this is an over‑eager fix that trades one problem (blowouts) for two (flattened VL and a leaky sky abstraction).


🧠 Learnings used
Learnt from: Dlizzio
Repo: doodlum/skyrim-community-shaders PR: 2000
File: src/WeatherEditor/EditorWindow.cpp:1271-1274
Timestamp: 2026-03-22T18:40:49.633Z
Learning: Repo: doodlum/skyrim-community-shaders — Maintainer preference (PR `#2000` on 2026-03-22): In src/WeatherEditor/EditorWindow.cpp within EditorWindow::RenderUI, keep `resetLayout = false;` at the end of the frame (after PaletteWindow::Draw). The reset is intentionally one-shot for windows rendered that frame; closed windows are allowed to reopen with their previous geometry. Do not move the clear later or broadcast resets to closed windows.

Learnt from: Dlizzio
Repo: doodlum/skyrim-community-shaders PR: 2000
File: src/WeatherEditor/EditorWindow.cpp:1239-1244
Timestamp: 2026-03-22T18:32:22.461Z
Learning: In doodlum/skyrim-community-shaders (PR `#2000`, 2026-03-22), maintainer preference: keep the default browser width logic in src/WeatherEditor/EditorWindow.cpp within EditorWindow::RenderUI — browserWidth = min(availableWidth * 0.5f, 960.0f * Util::GetUIScale()) is applied unconditionally (before checking settings.showViewport) to preserve a consistent left-rail width on first-use/reset. Do not change this to fill full width when the viewport is hidden.

Learnt from: jiayev
Repo: doodlum/skyrim-community-shaders PR: 1947
File: package/Shaders/DeferredCompositeCS.hlsl:234-243
Timestamp: 2026-03-14T08:35:42.651Z
Learning: In `package/Shaders/DeferredCompositeCS.hlsl` (doodlum/skyrim-community-shaders), the fallback non-IBL SKYLIGHTING specular path intentionally double-weights with `skylightingSpecular`: `dalcScaled` is computed as `IrradianceToGamma(IrradianceToLinear(directionalAmbientColorSpecular) * skylightingSpecular)`, and the final `finalIrradiance` is then `lerp(specularIrradiance, specularIrradianceReflections, skylightingSpecular)`. This is original engine logic preserved from before PR `#1947` and should not be flagged as a double-attenuation bug.

Learnt from: Dlizzio
Repo: doodlum/skyrim-community-shaders PR: 1950
File: package/Shaders/Lighting.hlsl:2008-2012
Timestamp: 2026-03-07T00:53:21.267Z
Learning: In doodlum/skyrim-community-shaders PR `#1950`, the maintainer (Dlizzio) confirmed that per-axis normal reorientation for triplanar-projected normals/detail in package/Shaders/Lighting.hlsl is not required for their use case; the current approach intentionally mixes samples without axis-specific swizzle/sign correction.

Learnt from: Dlizzio
Repo: doodlum/skyrim-community-shaders PR: 1966
File: package/Shaders/ISVolumetricLightingGenerateCS.hlsl:0-0
Timestamp: 2026-03-11T08:05:10.801Z
Learning: In doodlum/skyrim-community-shaders, the `sqrt()` applied to `CloudShadows::GetCloudShadowMult()` in `package/Shaders/ISVolumetricLightingGenerateCS.hlsl` is intentional. The maintainer (Dlizzio) confirmed it is used to increase cloud shadow strength at harsh angles for volumetric lighting, and should not be removed or replaced with a direct linear multiply.

Learnt from: jiayev
Repo: doodlum/skyrim-community-shaders PR: 0
File: :0-0
Timestamp: 2025-08-03T18:37:19.690Z
Learning: ISReflectionsRayTracing.hlsl and ISWorldMap.hlsl in the skyrim-community-shaders repository are image-space post-processing shaders that perform color sampling and blending operations that need proper linear color space handling for the linear lighting system. ISReflectionsRayTracing handles screen-space reflections and should use conditional Color::IrradianceToLinear/Gamma conversions similar to ISCompositeLensFlareVolumetricLighting.hlsl. ISWorldMap performs 7x7 color accumulation that should be done in linear space similar to the pattern used in ISSAOComposite.hlsl.

Learnt from: alandtse
Repo: doodlum/skyrim-community-shaders PR: 0
File: :0-0
Timestamp: 2025-06-24T07:17:36.604Z
Learning: When reviewing PRs, always clarify the scope if there are multiple related features or dependencies. WeatherPicker was a separate PR that was already merged, while this PR focuses specifically on WetnessEffects climate preset system enhancements.

Learnt from: alandtse
Repo: doodlum/skyrim-community-shaders PR: 2084
File: src/ShaderCache.cpp:1646-1649
Timestamp: 2026-04-10T07:34:27.849Z
Learning: In `src/ShaderCache.cpp` (doodlum/skyrim-community-shaders PR `#2084`), `GetImagespaceShaderDescriptor` intentionally returns `false` for VR when a shader is not reverse-engineered. Returning `false` causes `ResolveImageSpaceDescriptor` to return `false`, which makes all callers (GetVertexShader, GetPixelShader, GetComputeShader, CompileShader) skip custom shader handling and defer to the vanilla shader. This is the correct pattern for un-RE'd imagespace shaders on VR — do not flag it as "skipping all custom VR handling" or suggest gating on HDR feature state.

Learnt from: alandtse
Repo: doodlum/skyrim-community-shaders PR: 1941
File: package/Shaders/Common/ShadowSampling.hlsli:160-163
Timestamp: 2026-04-03T01:48:34.867Z
Learning: In `package/Shaders/Common/ShadowSampling.hlsli` (doodlum/skyrim-community-shaders PR `#1941`), the directional shadow fade in `GetLightingShadow` is intentionally computed as `fadeStart = shadow.EndSplitDistances.y * (1.0 - FadeWindow)` where `FadeWindow = 0.1`. This anchors the fade to the last 10% of the absolute far-cascade distance (`EndSplitDistances.y`), not to the cascade span. The narrow window is deliberate so shadows dissolve only at the hard far-cutoff without prematurely fading across the whole cascade range. Do not suggest using `lerp(StartSplitDistances.y, EndSplitDistances.y, 1.0 - FadeWindow)` as a fix.

Learnt from: jiayev
Repo: doodlum/skyrim-community-shaders PR: 1947
File: features/Dynamic Cubemaps/Shaders/DynamicCubemaps/DynamicCubemaps.hlsli:107-115
Timestamp: 2026-03-14T08:35:02.326Z
Learning: In `features/Dynamic Cubemaps/Shaders/DynamicCubemaps/DynamicCubemaps.hlsli`, the pattern of scaling `directionalAmbientColorSpecular` by `skylightingSpecular` (via `dalcScaled`) before the final `lerp(specularIrradiance, specularIrradianceReflections, skylightingSpecular)` is intentional pre-existing behavior preserved from the original implementation. Do not flag this as double-attenuation; the combined attenuation is by design.
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Comment thread features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli Outdated
Comment thread features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (1)
package/Shaders/ISApplyVolumetricLighting.hlsl (1)

49-50: ⚠️ Potential issue | 🟠 Major

Clamp after intensity scaling, not on the raw sample.

Line 49 still changes the curve before g_IntensityX_TemporalY.x is applied: a raw sample of 2.0 with intensity 0.4 becomes 0.4 instead of 0.8. Keep the cap on the scaled value only.

🐛 Proposed fix
-	float vlSample = min(VLTex.SampleLevel(VLSampler, float3(input.TexCoord, repartition), 0).x, 1.0);
+	float vlSample = VLTex.SampleLevel(VLSampler, float3(input.TexCoord, repartition), 0).x;
 	float vl = min(g_IntensityX_TemporalY.x * vlSample, 1.0);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package/Shaders/ISApplyVolumetricLighting.hlsl` around lines 49 - 50, The
sample is being clamped before intensity is applied: remove the min(...) clamp
around vlSample (the value produced by VLTex.SampleLevel using VLSampler and
repartition) so vlSample stores the raw sampled x value, then apply the
intensity scale with g_IntensityX_TemporalY.x and clamp the result when
computing vl (i.e., clamp only the scaled value stored in vl); update references
to vlSample and vl in ISApplyVolumetricLighting.hlsl accordingly.
🧹 Nitpick comments (3)
package/Shaders/ISApplyVolumetricLighting.hlsl (2)

89-89: Drop the redundant non-temporal upper clamp.

adjustedVl is already saturate(...) from Line 54, so this min does not change behavior.

♻️ Proposed cleanup
-		psout.VL = min(adjustedVl, 1.0);
+		psout.VL = adjustedVl;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package/Shaders/ISApplyVolumetricLighting.hlsl` at line 89, psout.VL is being
clamped again with min(adjustedVl, 1.0) even though adjustedVl is already
produced via saturate(...) (from the earlier computation), so remove the
redundant clamp by assigning psout.VL = adjustedVl; update the assignment that
currently reads psout.VL = min(adjustedVl, 1.0) to simply use adjustedVl (keep
references to adjustedVl and psout.VL intact).

1-1: Add an issue-closing reference if this fix has a tracked bug.

The PR is a bug fix, but the provided description does not include Fixes #.../Closes #.... Add one if there is a corresponding issue. As per coding guidelines, “Suggest adding appropriate GitHub keywords: Fixes #123 or `Closes `#123 for bug fixes.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package/Shaders/ISApplyVolumetricLighting.hlsl` at line 1, This PR fixes a
bug but the PR description lacks an issue-closing keyword; update the PR
description to include a GitHub keyword referencing the tracked issue (e.g.,
"Fixes `#123`" or "Closes `#123`") so the fix will auto-close the corresponding
issue—mention the impacted file ISApplyVolumetricLighting.hlsl (the added
include "Common/DummyVSTexCoord.hlsl") in the description for clarity.
package/Shaders/Sky.hlsl (1)

242-243: Replace 255.0f with a named constant.

The / 255.0f encodes an assumed 8-bit quantization step for the dither amplitude; past review feedback on this PR has repeatedly called out magic numbers. Please pull it into a named constant (e.g. kHdrSunDitherQuantum = 1.0f / 255.0f) alongside the other HDR sun constants in HDRSun.hlsli, and use saturate(hdrSunGain - 1.0f) * kHdrSunDitherQuantum. Also worth a brief comment that the -0.5 recenter assumes InterleavedGradientNoise returns [0,1].

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package/Shaders/Sky.hlsl` around lines 242 - 243, Replace the magic constant
255.0f with a named constant: add kHdrSunDitherQuantum = 1.0f / 255.0f to
HDRSun.hlsli alongside the other HDR sun constants, then update the usage in
Sky.hlsl (the expression in the baseColor.xyz update that currently uses
(saturate(hdrSunGain - 1.0f) / 255.0f)) to use saturate(hdrSunGain - 1.0f) *
kHdrSunDitherQuantum; also add a short comment next to the
Random::InterleavedGradientNoise(...) -0.5 recenter noting that it assumes
InterleavedGradientNoise returns [0,1].
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@package/Shaders/ISApplyVolumetricLighting.hlsl`:
- Line 87: The temporal output currently only caps the upper bound using
min(..., 1.0) which still allows negative values from previousVl to pass
through; change the assignment for psout.VL (the lerp(adjustedVl, previousVl,
temporalContribution * isValid) expression) to clamp/saturate the final result
to [0,1] so both lower and upper bounds are enforced (i.e., wrap the lerp result
with clamp(..., 0.0, 1.0) or saturate(...)).

In `@package/Shaders/Sky.hlsl`:
- Around line 239-246: When HDRSun::IsHdrSunActive() is true we must make DITHER
and non-DITHER permutations behave the same except for the added noise; update
the block around baseColor/skyScale so that either (A) skyScale is set to 0 and
the small quantization dither via Random::InterleavedGradientNoise is applied
for both DITHER and non-DITHER paths (hoist skyScale = 0 and the dither
injection out of the `#if` !defined(DITHER) block), or (B) skip applying
hdrSunGain to baseColor for permutations that carry DITHER so hdrSunGain
multiplication and the subsequent additive sky tint occur identically — modify
the logic referencing hdrSunGain, baseColor, skyScale, HDRSun::IsHdrSunActive()
and Random::InterleavedGradientNoise to ensure both code paths converge except
for the actual noise injection controlled by the DITHER macro.

---

Duplicate comments:
In `@package/Shaders/ISApplyVolumetricLighting.hlsl`:
- Around line 49-50: The sample is being clamped before intensity is applied:
remove the min(...) clamp around vlSample (the value produced by
VLTex.SampleLevel using VLSampler and repartition) so vlSample stores the raw
sampled x value, then apply the intensity scale with g_IntensityX_TemporalY.x
and clamp the result when computing vl (i.e., clamp only the scaled value stored
in vl); update references to vlSample and vl in ISApplyVolumetricLighting.hlsl
accordingly.

---

Nitpick comments:
In `@package/Shaders/ISApplyVolumetricLighting.hlsl`:
- Line 89: psout.VL is being clamped again with min(adjustedVl, 1.0) even though
adjustedVl is already produced via saturate(...) (from the earlier computation),
so remove the redundant clamp by assigning psout.VL = adjustedVl; update the
assignment that currently reads psout.VL = min(adjustedVl, 1.0) to simply use
adjustedVl (keep references to adjustedVl and psout.VL intact).
- Line 1: This PR fixes a bug but the PR description lacks an issue-closing
keyword; update the PR description to include a GitHub keyword referencing the
tracked issue (e.g., "Fixes `#123`" or "Closes `#123`") so the fix will auto-close
the corresponding issue—mention the impacted file ISApplyVolumetricLighting.hlsl
(the added include "Common/DummyVSTexCoord.hlsl") in the description for
clarity.

In `@package/Shaders/Sky.hlsl`:
- Around line 242-243: Replace the magic constant 255.0f with a named constant:
add kHdrSunDitherQuantum = 1.0f / 255.0f to HDRSun.hlsli alongside the other HDR
sun constants, then update the usage in Sky.hlsl (the expression in the
baseColor.xyz update that currently uses (saturate(hdrSunGain - 1.0f) / 255.0f))
to use saturate(hdrSunGain - 1.0f) * kHdrSunDitherQuantum; also add a short
comment next to the Random::InterleavedGradientNoise(...) -0.5 recenter noting
that it assumes InterleavedGradientNoise returns [0,1].
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d186f738-fd68-4245-a040-8b89bfdb659c

📥 Commits

Reviewing files that changed from the base of the PR and between bd7ca76 and ee27747.

📒 Files selected for processing (3)
  • features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli
  • package/Shaders/ISApplyVolumetricLighting.hlsl
  • package/Shaders/Sky.hlsl
🚧 Files skipped from review as they are similar to previous changes (1)
  • features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli

Comment thread package/Shaders/ISApplyVolumetricLighting.hlsl Outdated
Comment thread package/Shaders/Sky.hlsl Outdated
Comment thread package/Shaders/Sky.hlsl
Comment thread package/Shaders/Sky.hlsl Outdated
Comment thread package/Shaders/Sky.hlsl Outdated
Comment thread features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli Outdated
@doodlum
Copy link
Copy Markdown
Collaborator

doodlum commented Apr 20, 2026

note that artistic changes to sun shape are outside of project scope

@davo0411
Copy link
Copy Markdown
Collaborator Author

note that artistic changes to sun shape are outside of project scope

my whole goal has been to increase brightness without size. its proved very tricky to increase nits to peak without also increasing some of the low alpha parts of the textures, or having VL increase slightly.

@davo0411 davo0411 requested a review from doodlum April 23, 2026 22:36
Comment thread features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli Outdated
Comment thread features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli Outdated
Comment thread features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli Outdated
Comment thread features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli Outdated
Comment thread features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli Outdated
Comment thread features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli Outdated
Comment thread package/Shaders/ISApplyVolumetricLighting.hlsl
@davo0411 davo0411 requested a review from doodlum April 27, 2026 10:25
@SkrubbySkrubInAShrub
Copy link
Copy Markdown
Collaborator

Visually it looks good to me

Comment thread features/HDR Display/Shaders/HDRDisplay/HDRSun.hlsli Outdated
@doodlum doodlum changed the title fix(HDR): clamp vol lighting, rewrite hdr sun chore(HDR): rewrite hdr sun May 6, 2026
@doodlum doodlum changed the title chore(HDR): rewrite hdr sun chore(hdr): rewrite hdr sun May 6, 2026
@doodlum doodlum merged commit 8fcaef6 into community-shaders:dev May 6, 2026
15 checks passed
SkrubbySkrubInAShrub pushed a commit that referenced this pull request May 14, 2026
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: doodlum <15017472+doodlum@users.noreply.github.com>
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.

4 participants