Skip to content

fix: fog flicker in unified water#1772

Merged
davo0411 merged 1 commit into
community-shaders:devfrom
davo0411:uf-fixes
Jan 27, 2026
Merged

fix: fog flicker in unified water#1772
davo0411 merged 1 commit into
community-shaders:devfrom
davo0411:uf-fixes

Conversation

@davo0411
Copy link
Copy Markdown
Collaborator

@davo0411 davo0411 commented Jan 27, 2026

fixes flicker, also results in better final fog colour with less "glow"
before/after
20BF3D~1

2001AF~1

Summary by CodeRabbit

  • Bug Fixes
    • Improved water fog rendering by updating fog distance calculations for more accurate visual representation.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 27, 2026

📝 Walkthrough

Walkthrough

Modified the fog distance calculation in a water shader by replacing the W-component of world position with the 3D Euclidean distance magnitude. This changes how fog intensity is evaluated based on camera distance rather than a transformed scalar value.

Changes

Cohort / File(s) Summary
Water Shader Fog Calculation
package/Shaders/Water.hlsl
Replaced input.WPosition.w with length(input.WPosition.xyz) in fog distance factor computation (2 locations), switching from W-component scalar to 3D magnitude-based distance evaluation

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • jiayev
  • doodlum

Poem

🐰 A shimmer of water so blue and so bright,
Distance now measured by true spatial sight,
No W-component shall cloud up this stream,
Length-based fog paints a realistic dream,
Two tiny tweaks make the water pristine!

🚥 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 directly and clearly describes the main change: fixing fog flicker in unified water, which matches the primary objective of the pull request.
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.


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

Using provided base ref: 50e2929
Using base ref: 50e2929
Base commit date: 2026-01-25T17:17:09-08:00 (Sunday, January 25, 2026 05:17 PM)
No actionable suggestions for changed features.

@github-actions
Copy link
Copy Markdown

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

@alandtse
Copy link
Copy Markdown
Collaborator

What's the reasoning for the changes? Are we changing the algorithm significantly? In other words why are the parameters used before being dropped?

@davo0411
Copy link
Copy Markdown
Collaborator Author

What's the reasoning for the changes? Are we changing the algorithm significantly? In other words why are the parameters used before being dropped?

the old input.WPosition.w was distance calculated per-vertex then interpolated, which broke with unified water.
length(input.WPosition.xyz) recalculates distance per-pixel from the interpolated position which is stable for uw

all the other fog params are identical (FogParam.x/y, FogFarColor.w, FresnelRI.y).
The fog looks a bit different because length(lerp(A,B)) is not the same as lerp(length(A), length(B)), but that's actually more accurate and it doesn't flicker anymore.

@davo0411 davo0411 merged commit 245a433 into community-shaders:dev Jan 27, 2026
16 checks passed
@alandtse
Copy link
Copy Markdown
Collaborator

Please also consider the commit message.
fix(unified water): fog flicker

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.

3 participants