CaffeineMC / sodium

A Minecraft mod designed to improve frame rates and reduce micro-stutter
Other
4.81k stars 809 forks source link

Entities become invisible in culled chunks when they shouldn't #2696

Open Felix14-v2 opened 3 months ago

Felix14-v2 commented 3 months ago

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 https://github.com/user-attachments/assets/a0998bef-0e81-4412-a912-d6a524b7a97a The interesting part is that disabling the "Entity culling" option does nothing: https://github.com/user-attachments/assets/cf2c41db-c850-409a-979a-abaeaaa8d22a

Reproduction Steps

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

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.

https://github.com/user-attachments/assets/a1199ebc-4670-4285-bdb7-299aeafe7157

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.

Altirix commented 1 month ago

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

jellysquid3 commented 1 month ago

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.

Altirix commented 1 month ago

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

Felix14-v2 commented 1 month ago

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 ._.