Skip to content

build(hlsl): address warnings#2103

Merged
doodlum merged 1 commit into
community-shaders:devfrom
alandtse:shader_warnings
Apr 12, 2026
Merged

build(hlsl): address warnings#2103
doodlum merged 1 commit into
community-shaders:devfrom
alandtse:shader_warnings

Conversation

@alandtse
Copy link
Copy Markdown
Collaborator

@alandtse alandtse commented Apr 12, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Improved PQ color encoding and HDR tone-mapping stability to prevent visual artifacts in edge cases.
  • Improvements

    • Enhanced texture sampling quality in lighting and specular calculations through better gradient-based filtering.
    • Optimized shader calculations for improved performance and numerical stability.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 12, 2026

📝 Walkthrough

Walkthrough

This PR modifies eight shader files to improve numerical safety and parameter propagation. Changes include adding clamping and absolute-value operations before exponentiation, propagating UV derivatives through the lighting pipeline, replacing division with bit-shift operations, and initializing a shader output struct.

Changes

Cohort / File(s) Summary
Exponentiation Safety
package/Shaders/Common/Color.hlsli, package/Shaders/ISHDR.hlsl
Added clamping and absolute-value operations before pow() calls to prevent negative-value exponentiation: pow(max(0.0, color), M1) and pow(abs(A), 1.0/3.0) patterns replace direct pow() calls.
UV Derivative Propagation
package/Shaders/Common/LightingEval.hlsli, package/Shaders/Lighting.hlsl
Extended lighting functions to accept and propagate UV derivatives (uv_ddx, uv_ddy): EvaluateLighting and VanillaSpecular signatures updated to pass derivatives through the lighting pipeline using gradient-based texture sampling.
Arithmetic Operation Changes
package/Shaders/Common/VR.hlsli, package/Shaders/Menu/BackgroundBlurHorizontal.hlsl, package/Shaders/Menu/BackgroundBlurVertical.hlsl
Replaced integer division with bitwise right-shift for half-value computation: samples / 2samples >> 1 and frameDim.x / 2(uint)frameDim.x >> 1.
Initialization
package/Shaders/Water.hlsl
Changed shader output struct declaration from uninitialized to explicitly zeroed: VS_OUTPUT vsout = (VS_OUTPUT)0;.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • doodlum
  • jiayev

Poem

🐰 With pow and clamps, we find the way,
Safe from negatives that led astray!
Derivatives flow through the lighting's dance,
Right-shifts replace division's stance—
Shaders bloom with proper care! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main objective of the PR, which is to address shader compilation warnings across multiple HLSL files by adding input clamping and modifying arithmetic operations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

@github-actions
Copy link
Copy Markdown

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

🤖 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/ISHDR.hlsl`:
- Around line 177-179: The contrast normalization divides by avgValue.x which
can be zero; update the computation of contrastedColorModified (and its use when
blending into contrastedColor) to guard avgValue.x with a small positive epsilon
or conditional fallback so you never divide by zero — e.g., compute a safeAvg =
max(avgValue.x, epsilon) and use safeAvg in the pow(abs(tintedColor) / safeAvg,
Cinematic.z) * safeAvg * sign(tintedColor) expression, and ensure the
lerp/saturate blend still behaves correctly when avgValue.x was originally zero.
🪄 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: 8aa84570-11d5-4213-8b6e-11468c65ef1d

📥 Commits

Reviewing files that changed from the base of the PR and between 8a67f36 and 2d22a94.

📒 Files selected for processing (8)
  • package/Shaders/Common/Color.hlsli
  • package/Shaders/Common/LightingEval.hlsli
  • package/Shaders/Common/VR.hlsli
  • package/Shaders/ISHDR.hlsl
  • package/Shaders/Lighting.hlsl
  • package/Shaders/Menu/BackgroundBlurHorizontal.hlsl
  • package/Shaders/Menu/BackgroundBlurVertical.hlsl
  • package/Shaders/Water.hlsl

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

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

@doodlum doodlum merged commit d556a95 into community-shaders:dev Apr 12, 2026
17 checks passed
YtzyFvra pushed a commit to YtzyFvra/skyrim-community-shaders that referenced this pull request Apr 19, 2026
ParticleTroned pushed a commit to ParticleTroned/skyrim-community-shaders that referenced this pull request May 2, 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.

2 participants