Sodium

Sodium

44M Downloads

Entities become invisible in culled chunks when they shouldn't

Felix14-v2 opened this issue ยท 4 comments

commented

Bug Description

In some scenarios, if an entity is partially hidden in a culled chunk section, the entity model can become invisible until you forcefully load the chunk section.

Demo
Minecraft_.1.21.-.Singleplayer.2024-08-20.21-40-48.mp4

The interesting part is that disabling the "Entity culling" option does nothing:

Minecraft_.1.21.-.Singleplayer.2024-08-20.21-40-48.mp4

Reproduction Steps

Preparing the area (you can just load the attached world)

  • Create an empty world with the "void" preset
  • Cover a chunk section with a solid block (example: /fill -1 -1 -1 16 16 16 stone)
  • Unload the chunk and load it again in a way you prefer (for example, just rejoin the world)
    Triggering the bug
  • Place an entity on top of the cube you've just created and disable gravity for it (example: /summon minecraft:armor_stand 5 17 5 {NoGravity:1b})
  • Tweak the vertical position of the entity to hide its hitbox origin inside the chunk section (example: /execute as @e[type=minecraft:armor_stand] at @s run tp ~ ~-1.001 ~)
  • The entity will immediately disappear (expected: it should be visible)

Debug info

latest.log
crash-2024-08-20_22.41.21-client.txt

Additional

I heard about this behavior from a server administrator, who complained to me that Sodium is breaking decorations on his server. I debugged it a bit and found this bug. So this may be a real-world scenario, not just a limited edge case.

Minecraft_.1.21.-.Singleplayer.2024-08-20.21-27-28.mp4

Lobby.zip

By the way, you can see another issue with the entity shadowing in the video above (0:02-0:03), but that's unrelated.

commented

This is a Vanilla bug to some extent. its not the same behaviour as sodium but neither vanilla or sodium have a guarentee on rendering these entitites. This does not seem to be a result of entity culling.

Not exactly sure whats happening but my guess is sometimes the section under is considered visable in some locations and not visable in others. which means this behaviour depends on a section being marked visable when its not.

2024-10-25_23 31 01
2024-10-25_23 39 40

commented

Our renderer will construct a bounding box around the entity and then scan the entire volume to determine if there are any visible sections intersecting with it. What seems to be going wrong is that armor stands have no dimensions, which makes it so that Sodium will only check the section which intersects the entity's origin point (the feet.)

The fact this requires the chunk to be unloaded and loaded makes me think there is a serialization bug with Armor Stands which causes their bounding box to be initialized incorrectly.

commented

Our renderer will construct a bounding box around the entity and then scan the entire volume to determine if there are any visible sections intersecting with it. What seems to be going wrong is that armor stands have no dimensions, which makes it so that Sodium will only check the section which intersects the entity's origin point (the feet.)

should have also included a screenshot of what the test world looks like as there wasnt one in the original issue. as theres other entitites in there too. i didnt check too much but im pretty sure nothing is even getting to isEntityVisible, as the toggle for entity culling doesnt change it.

nvm they are actually all going into the isEntityVisible, seem to have the right bounding box and returning true.

2024-10-25_23 53 00

commented

should have also included a screenshot of what the test world looks like as there wasnt one in the original issue

I thought the video demonstrating the test world would be enough ._.