Sodium Reloaded (Unofficial)

Sodium Reloaded (Unofficial)

0 Downloads

Fix vanila bug MC-193656 in Sodium, or make the Fabric API fix compatible with Sodium

Lolothepro opened this issue ยท 5 comments

commented

FiniteReality/embeddium#110

Sodium+Fabric API:

2023-11-21.20-13-33.mp4

Fabric API:

https://cdn.discordapp.com/attachments/394433849251332096/1176601861537669160/2023-11-21_20-14-51.mp4

2023-11-21.20-17-25.mp4

Note: No github template was used, because I don't know if it's a bug or a feature request.

commented

The fix is in 1.20.5-rc1

commented

Fixed in 1.20.5

commented

The problem is caused by how we apply transformations to the packed normal data of each vertex. In vanilla, these transformations happen before the values are compressed/truncated. But with Sodium, we apply the transformations to the already truncated values, which means there is very little precision left at that point (only 8 bits per component). This is why the behavior you are seeing is so unstable.

I don't see an easy way to fix this without radically altering how the VertexBufferWriter works. We would have to move the encoding step to the very end (before it's written into a buffer), and have it only consume full-precision normals. This would break any other mods relying on Sodium's interface, and it would probably come with a performance penalty.

commented

The issue might be that Fabric API's mixin does not take effect on Sodium's call to Direction.getFacing here:

https://github.com/CaffeineMC/sodium-fabric/blob/0ae058b7b078b182fafc57c12de5059b22e088a0/src/main/java/me/jellysquid/mods/sodium/mixin/core/render/immediate/consumer/OverlayVertexConsumerMixin.java#L88

If that is the case, the best solution is probably for Sodium to ship its own version of the fix (suitably optimized, since Fabric still uses the dot product rather than comparing magnitudes).

EDIT: The cause is more nuanced than this, as replacing the getFacing call with Fabric's implementation manually does not fix the issue.

commented