Sodium

Sodium

44M Downloads

Sodium does not support Fabric's SimpleFluidRenderHandler API

TelepathicGrunt opened this issue ยท 4 comments

commented

Bug Description

When using the SimpleFluidRenderHandler API from Fabric API to render my fluid, this system no longer works when Sodium is present.

What the desired appearance of my fluid should look like. It has a bottom_layer block property that I increment slowly to make the fluid move slowly downward instead of by full blocks:

2024-01-09.19-32-57.mp4

What happens when Sodium is present. It ignores my rendering code and just treats my fluid like normal vanilla fluids with their ugly flowing behavior that does not work well for slow moving fluids:

2024-01-09.19-30-42.mp4

Here's my code implementation following how Fabric API desires it to be implemented:

https://github.com/TelepathicGrunt/Bumblezone/blob/4e07e27a93b4118d825d65ed62246135be968ff8/fabric-base/src/main/java/com/telepathicgrunt/the_bumblezone/fluids/fabric/HoneyFluidRenderHandler.java#L35

It appears Sodium does not support Fabric API and instead, circumvents Fabric API entirely for fluid rendering which is detrimental to mods that try to do unique fluid looks. I do not have a solution yet for myself to workaround this without adding Sodium as a compileOnly dependency to write dedicated code for it.

Reproduction Steps

Put on Bumblezone, MidnightLib, Sodium, and Indium. Get Honey Bucket from Creative Menu. Place the fluid high up. Observe the different in how it flows.

Log File

latest.log

Crash Report

N/A

commented

Notes from conversations on Discord, so they don't get lost:

Sodium needs to call Fabric's renderFluid hook in order for this to work, but doing that unconditionally would cause all fluid rendering to use the vanilla code path, which is not efficient. The cleanest solution I can think of is to only call this method if it has actually been overriden from the default implementation (this probably requires using reflection with a cache, something along the lines of what Lithium does).

Another problem is that Fabric's hook expects a vanilla VertexConsumer while Sodium uses its own chunk mesh writing APIs. There would need to be a VertexConsumer wrapper class introduced for mod code to work without changes. Embeddium's SinkingVertexBuilder is an example of this.

commented

A pull request has been opened to resolve this issue: #2326

commented

Support has been added with 2272018, which will be published with Sodium 0.6.0.

commented

@TelepathicGrunt This workaround in your mod should no longer be necessary. Which is probably for the best, because it seems to increase memory usage significantly (a 2 MiB off-heap allocation per chunk building thread, roughly ~60 MB on my system.) ๐Ÿ˜… Would you be able to remove it when we publish Sodium 0.6? Thanks!