Skip to content

fix(water): fix water blending by setting buffers to RGBA16#2386

Merged
doodlum merged 2 commits into
devfrom
fix-water-blend-hdr
May 20, 2026
Merged

fix(water): fix water blending by setting buffers to RGBA16#2386
doodlum merged 2 commits into
devfrom
fix-water-blend-hdr

Conversation

@jiayev
Copy link
Copy Markdown
Collaborator

@jiayev jiayev commented May 20, 2026

This pull request updates the water blending shader and its associated render targets to improve how water coverage and history are handled, ensuring more accurate blending and support for higher-precision data. The main changes include switching to four-component (float4) formats for water history, updating the logic for water coverage calculation, and adjusting render target formats for better precision.

Shader and Data Format Updates:

  • Changed Color1 in PS_OUTPUT from float3 to float4 to store an additional water coverage value. (package/Shaders/ISWaterBlend.hlsl)
  • Updated waterHistoryTex from Texture2D<float3> to Texture2D<float4> to store and access the water coverage (alpha channel) in addition to color. (package/Shaders/ISWaterBlend.hlsl)
  • Changed render target formats for water buffers from DXGI_FORMAT_R11G11B10_FLOAT to DXGI_FORMAT_R16G16B16A16_FLOAT for higher precision and to support four channels. (src/Deferred.cpp)

Water Coverage and Blending Logic:

  • Replaced the previous history coverage calculation with a new GetWaterCoverage function, and updated the threshold constant name for clarity. (package/Shaders/ISWaterBlend.hlsl)
  • Updated blending logic in the pixel shader to use the new water coverage value (waterHistory.w) and output it in the alpha channel of Color1. (package/Shaders/ISWaterBlend.hlsl) [1] [2]

Summary by CodeRabbit

  • Bug Fixes
    • Improved water coverage blending and transparency calculations for enhanced accuracy and visual consistency in water rendering across all scenes
    • Upgraded water render target color depth and precision specifications to deliver higher quality water visual effects with improved rendering fidelity and clarity

Review Change Stack

@jiayev jiayev changed the title fix(water): fix water blending by setting to RGBA16 fix(water): fix water blending by setting buffers to RGBA16 May 20, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 20, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e4f27453-f71b-4e43-9066-e96542d028b2

📥 Commits

Reviewing files that changed from the base of the PR and between 49b5288 and e9c026e.

📒 Files selected for processing (2)
  • package/Shaders/ISWaterBlend.hlsl
  • src/Deferred.cpp

📝 Walkthrough

Walkthrough

The PR refactors water history blending in the shader to use a float4 representation with coverage encoded in the alpha channel. The shader output struct, texture sampling, namespace helpers, and main blending logic are updated accordingly. Render targets supporting TAA water blending are upgraded to DXGI_FORMAT_R16G16B16A16_FLOAT to accommodate the wider data format.

Changes

Water History Float4 Refactor

Layer / File(s) Summary
Water shader history and coverage refactoring
package/Shaders/ISWaterBlend.hlsl
PS_OUTPUT.Color1 changes from float3 to float4 to store coverage in alpha. waterHistoryTex retyped from Texture2D<float3> to Texture2D<float4>. WaterBlend namespace removes FullHistoryCoverageThreshold, SaturateRange, and GetHistoryCoverage; adds FullWaterCoverageThreshold and GetWaterCoverage(waterMask). Main function updates history sampling to float4, changes blend gate from historyCoverage > 0.0 to waterHistory.w > 0.0, multiplies blend factor by waterHistory.w, and outputs Color1 as float4(finalColor, GetWaterCoverage(waterMask)).
Render target format alignment
src/Deferred.cpp
Water TAA render targets kWATER_1 and kWATER_2 format upgraded from DXGI_FORMAT_R11G11B10_FLOAT to DXGI_FORMAT_R16G16B16A16_FLOAT to support float4 color output with coverage alpha channel.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • alandtse
  • doodlum

Poem

🐰 Water flows through channels wide,
Now with coverage in its stride,
Float4 blends with history's might,
Render targets shine so bright!
Alpha channels hold the key,
To fluid dynamics, wild and free! 💧✨

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing water blending by switching render buffers to RGBA16 format for higher precision and coverage data support.
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.

✏️ 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 fix-water-blend-hdr

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.21.0)

OpenGrep fatal error (exit code 2): [00.16][ERROR]: Error: exception Unix_error: No such file or directory stat src/Deferred.cpp
Raised by primitive operation at UTmp.replace_named_pipe_by_regular_file_if_needed in file "libs/commons/UTmp.ml", line 145, characters 8-27
Called from Scan_CLI.replace_target_roots_by_regular_files_where_needed.(fun) in file "src/osemgrep/cli_scan/Scan_CLI.ml", lines 1086-1087, characters 19-65
Called from List_.fast_map in file "libs/commons/List_.ml", line 81, characters 17-20
Called from Scan_CLI.re


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.

@SkrubbySkrubInAShrub
Copy link
Copy Markdown
Collaborator

fixes #2387

@github-actions
Copy link
Copy Markdown

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

@doodlum doodlum merged commit d66da81 into dev May 20, 2026
14 checks passed
@jiayev jiayev deleted the fix-water-blend-hdr branch May 22, 2026 02:37
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