Skip to content

fix(water): remove water lights specular when llf on - #2403

Open
jiayev wants to merge 1 commit into
devfrom
fixwaterspec
Open

fix(water): remove water lights specular when llf on#2403
jiayev wants to merge 1 commit into
devfrom
fixwaterspec

Conversation

@jiayev

@jiayev jiayev commented May 23, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • Bug Fixes
    • Improved water shader rendering to fix specular light accumulation under certain configurations.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The Water.hlsl pixel shader now conditionally skips the per-specular-light accumulation loop when LIGHT_LIMIT_FIX is defined, allowing alternative specular and reflection logic to execute instead.

Changes

Water Shader Specular Light Compilation Guard

Layer / File(s) Summary
Conditional specular-light accumulation under LIGHT_LIMIT_FIX
package/Shaders/Water.hlsl
The specular-light loop (lines 1146–1160) is wrapped with #if !defined(LIGHT_LIMIT_FIX) ... #endif``, so it executes only when the flag is not enabled, otherwise the code proceeds to subsequent specular/reflection logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • doodlum
  • alandtse

🐰 A shader loop takes a break today,
When LIGHT_LIMIT_FIX comes out to play,
Specular dreams skip their gleaming dance,
While reflection logic gets its chance! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title directly addresses the main change: conditionally skipping the per-specular-light accumulation loop in Water.hlsl when LIGHT_LIMIT_FIX (llf) is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fixwaterspec

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.

@jiayev jiayev changed the title fix(water): remove water lights spec ular when llf on fix(water): remove water lights specular when llf on May 23, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

1149-1160: ⚡ Quick win

Polish PR metadata for clarity and traceability

Suggested commit title (≤50 chars): fix(water): skip legacy specular loop with llf
If this fixes a tracked bug, add an issue keyword in the PR description, e.g. Fixes #<id>.

As per coding guidelines, **/*: "When reviewing PRs, please provide suggestions for Conventional Commit Titles ... [and] Issue References ..."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@package/Shaders/Water.hlsl` around lines 1149 - 1160, Update the PR metadata:
set the commit/PR title to "fix(water): skip legacy specular loop with llf" and
add an issue reference (e.g. "Fixes #<id>") in the PR description if this change
resolves a tracked bug; no code changes are required in the
LIGHT_LIMIT_FIX/NUM_SPECULAR_LIGHTS specular loop (the HLSL block with LightPos,
PosAdjust, input.WPosition, FresnelRI, etc.)—just update the commit message and
PR description to follow the Conventional Commits guideline and include the
issue keyword for traceability.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@package/Shaders/Water.hlsl`:
- Around line 1149-1160: Update the PR metadata: set the commit/PR title to
"fix(water): skip legacy specular loop with llf" and add an issue reference
(e.g. "Fixes #<id>") in the PR description if this change resolves a tracked
bug; no code changes are required in the LIGHT_LIMIT_FIX/NUM_SPECULAR_LIGHTS
specular loop (the HLSL block with LightPos, PosAdjust, input.WPosition,
FresnelRI, etc.)—just update the commit message and PR description to follow the
Conventional Commits guideline and include the issue keyword for traceability.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 0830b024-1479-4e1b-b03e-30bebfe56855

📥 Commits

Reviewing files that changed from the base of the PR and between bb6460d and 0b37a18.

📒 Files selected for processing (1)
  • package/Shaders/Water.hlsl

@doodlum doodlum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

pretty sure water is an extra pass. also water does not support portal strict lights, so this breaks portal strict lights on water. also check water-specific lights flag and how it's used

alandtse added a commit to alandtse/open-shaders that referenced this pull request Aug 2, 2026
* fix(water): stop double-counting specular under LLF

Water's vanilla per-light specular loop and LightLimitFix's own
clustered specular loop light the same surface from the same light
list via separate additive render passes, doubling specular for any
light both see. Gate the vanilla loop off under LIGHT_LIMIT_FIX, as
Lighting.hlsl already does for its own vanilla loop.

Doing that alone would silently drop specular from every
shadow-casting light, since LLF's water loop `continue`s past
Shadow-flagged lights instead of sampling their shadow. Mirror
RunGrass.hlsl's shadow-sampling pattern so those lights still
contribute.

Based on upstream community-shaders#2403,
which only did the first half; a maintainer review there flagged the
narrower regression this commit also fixes.

* fix(water): skip shadow lookup in reflections

GetShadowLightShadow reconstructs world position from this pixel's
camera-relative position, which is the mirrored reflection camera
during a reflection pass, not the main view -- sampling the shadow
map there would look up the wrong location. Gate it on inWorld and
!inReflection, matching Lighting.hlsl's equivalent call.
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