Sodium

Sodium

44M Downloads

Improve interaction between fluid sources and blocks above them

muzikbike opened this issue ยท 3 comments

commented

Request Description

While testing out fluid shape handling recently, I've noticed a bunch of weird, undesirable quirks of how vanilla does it, and have come up with a potential fix for all of these.

The solution is as follows: if a fluid source block (not a flowing fluid) is directly below a block with a full 16x16 solid bottom face, then the fluid source block should visually "snap" upwards to that block by itself becoming a 16x16 cube on its own.

Here's a visual demonstration of how this would work. The current behaviour:
2024-05-05_21 31 23

The fixed behaviour:
2024-05-05_21 31 25

This would fix, or allow for the fixing of, a handful of undesirable quirks of vanilla's fluid models. For starters, we'd already have fixed https://bugs.mojang.com/browse/MC-249344, a Bedrock Edition parity issue of sorts. Lava in a glass cube would now look as follows (no weird gap above it):
image

Secondly, this would permit more intuitive behaviour for face culling. Since the top face of water or lava would now be coplanar with any solid, opaque blocks above it (no more visual gap), then both the interior and exterior top faces can be outright culled if the block above would cull any other block below it. This would get rid of the following nonsense (https://bugs.mojang.com/browse/MC-175133), where water/lava inner top faces sometimes render against solid blocks even though they shouldn't (with the fix they would continue to render against the glass as before):
2024-05-05_21 38 30

Since the top faces of fluids would be culled by solid blocks, we'd get rid of this other annoyance where flooded caves display the top face of the fluid at every instance, but don't display any of the others (not even the inner planes). It might make it harder to tell if a cave is flooded when outside of it and in Spectator but since we can cull more unnecessary planes this way and it resolves an inconsistency this isn't a major loss by any means.
2024-05-05_20 52 42
2024-05-05_20 53 14

If it's possible to explicitly exclude flowing liquids (minecraft:flowing_water and minecraft:flowing_lava) from being culled at all times, while having it enabled for source units (minecraft:water and minecraft:lava), then this would also resolve #2470.

commented

This seems like a fix that does not only touch the renderer, as the water layers touch the block while vanilla doesn't, as it does seem like something with the server side though...

commented

I showed some screenshots on Discord last night to demonstrate how this would look in actual gameplay situations, so it might be worth posting them here as well for clarity.

Here's how a platform over water would look from above. Top image is the vanilla behaviour, bottom image is the new proposed behaviour. The difference here is virtually unnoticeable.
2024-05-06_13 35 57
2024-05-06_13 35 31

Here is it from just the right angle at the water's surface to expose the visual differences in height. The vanilla behaviour has a relatively clear gap here, which would not exist with the proposed fix as the water would bulge upwards by a pixel or so to fill it.
2024-05-05_22 08 21
2024-05-05_22 09 00

Here it is from below while in the water. Due to #2470, vanilla's behaviour is rather ugly since it renders a bunch of extra, unneeded planes around the edges, which randomly cut off as you go deeper under the shape. The fix would cut them off right as soon as the water is under the blocks, making edges clearer and perhaps cleaner.
2024-05-05_22 08 06
2024-05-05_22 08 50

Here's how things look if we clip into the blocks in Spectator mode. With the fix, we cull every top texture since it's no longer visible from the outside. Doing this will allow for the elimination of a lot of geometry in flooded overworld water and lava caves, and even more so in nether lava lakes.
2024-05-05_22 11 07
2024-05-05_22 10 37

Finally, here's one more graphic that shows the result of a fix for this and #2470. We have a 5x2x5 space here, and the 16 outer top blocks are water sources. There are no water sources on the bottom layer. With the current vanilla behaviour, due to erroneously culled internal planes, we cannot see the funnel shape from within the water - this issue is resolved with the changed behaviour. (Fixing just #2470 and not this would still make things look far better than in current vanilla, but the upper edges of the texture planes would stop just a few pixels shy of the top rather than stopping at the exact top as seen here.)
2024-05-05_22 18 40
2024-05-05_22 18 17

Again, as stated in last night's Discord conversation, more input is needed here to determine whether this change is worthwhile and preferable to vanilla's current way of handling fluids.

commented

We discussed this issue yesterday and consensus between contributors is that this is not a desired change for Sodium. Nevertheless, various other fluid rendering issues can remain open as they are potentially valid in their own right.