Skip to content

Improve Fluid Shaping#2931

Merged
douira merged 37 commits intoCaffeineMC:devfrom
douira:fix-waterlogging-slants
Mar 21, 2026
Merged

Improve Fluid Shaping#2931
douira merged 37 commits intoCaffeineMC:devfrom
douira:fix-waterlogging-slants

Conversation

@douira
Copy link
Contributor

@douira douira commented Dec 10, 2024

Refactors the fluid renderer to improve fluid shaping in a variety of situations. Profiling shows that the performance impact appears to be negligible.

Screenshots are ordered dev and then this patch.

Regular water slopes look the same.
water 1 dev
water 1 patch
water 2 dev
water 2 patch

Water slopes are nearly identical. I experimented with changing the sloping behavior and it didn't work out well.
water 3 dev
water 3 patch

Water shaping around stairs (foreground) and between stairs (further back): Water height doesn't propagate through the closed sides of block faces, fixing issues with unnecessarily bent water faces and water connecting to waterlogged blocks where it shouldn't.
Fixes #1211
water 4 dev
water 4 patch
water 5 dev
water 5 patch

The cave heuristic has been refined to search 2 blocks around and 1 block up (compared to 1 block around and 1 block up). This improves the appearance of inward up face culling somewhat. Player builds are still somewhat weird but generally improved.
To make the presentation more self-consistent and to avoid situations where seams in the fluid are visible from air spaces that the player could inhabit, some cases now have more fluid quads than before. In other cases, less faces are shown to make glass rendering more consistent. Glass being right above water doesn't constitute enough "air" to make it render inwards facing quads, but outwards facing quads will render to ensure the fluid is visible when viewing it through the glass from above.
Fixes #2470, nearly completely, to the point where I would call it fixed.
Fixes #2935 by providing a feasible yet pretty good cull heuristic.
Fixes #2947 by hiding down-facing fluid up quads against glass in all reasonable cases.
dev
patch
water 6 dev
water 6 patch

Outward up faces are now culled with the refined cave heuristic. This slightly increases rendering performance if there's a lot of flooded visible caves. I have reports of increased fps anywhere up to around 2 to 6%.
water 8 dev
water 8 patch

The test for bottom quad occlusion to show inward water quads on air, but not on glass for example. By using the same test for overlays as the sides, this more consistently shows and hides the inward bottom face.
Fixes #1210
Fixes #1212
water 7 dev
water 7 patch

Fixes #3523

@douira
Copy link
Contributor Author

douira commented Dec 15, 2024

ok I'm marking this as ready, what follows will be fixing any bugs we might find in further testing.

@douira douira marked this pull request as ready for review December 15, 2024 19:48
@douira
Copy link
Contributor Author

douira commented Dec 18, 2024

I've fixed a small bug with the flooded cave heuristic and added detailed documentation to the PR and the fluid renderer class itself.

@douira douira requested a review from jellysquid3 December 18, 2024 02:31
@douira douira force-pushed the fix-waterlogging-slants branch from 78b2d82 to 9c9b755 Compare December 22, 2024 00:23
@douira douira marked this pull request as draft March 29, 2025 23:38
@douira douira force-pushed the fix-waterlogging-slants branch from 9c9b755 to 4813513 Compare March 7, 2026 15:31
@douira douira force-pushed the fix-waterlogging-slants branch from 34b6463 to e4bed5b Compare March 19, 2026 16:53
@douira douira marked this pull request as ready for review March 19, 2026 16:53
@douira douira requested a review from IMS212 March 19, 2026 16:54
@douira douira modified the milestone: Sodium 0.8.7 Mar 19, 2026
Copy link
Member

@IMS212 IMS212 left a comment

Choose a reason for hiding this comment

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

Seems fine to me. Not very knowledgeable about fluid rendering, though.

@douira
Copy link
Contributor Author

douira commented Mar 21, 2026

Thanks! I've done a few rounds of testing and feedback. If something significant pops up after release, we can fix it.

douira added 21 commits March 21, 2026 16:01
refactor flooded cave heuristic iteration behavior,
make inner and outer up quad independently activated for better results in some cases
…logged blocks and hidden fluid culling.

allow using both the new and old fluid renderer implementation to compare
@douira douira force-pushed the fix-waterlogging-slants branch from e4bed5b to dfbbd28 Compare March 21, 2026 15:02
@douira douira merged commit 9b29cc1 into CaffeineMC:dev Mar 21, 2026
1 check passed
@douira douira deleted the fix-waterlogging-slants branch March 21, 2026 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment