godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.64k stars 20.1k forks source link

Occlusion Culling falsely culls large objects visible through small openings when touching the edge of the viewport #94210

Open unfa opened 1 month ago

unfa commented 1 month ago

Tested versions

Reproducible in 4.3-beta2 and 4.2.2-stable.

System information

Arch Linux w/ X11 and Windows 10 using Radeon RX6800XT

Issue description

Occlusioin culling falsely culls a large object that is mostly obsured, but still visible through an opening in a wall in certain spatial configurations.

Here the red block is visible (expected): Clipboard - July 10, 2024 11_13 PM-1

And here it is culled (unexpected): Clipboard - July 10, 2024 11_13 PM

Video demonstrations in Liblast project: https://youtu.be/xQW2PNNUggw (Godot 4.2.2-stable) https://youtu.be/kfxirWBtZQ4 (Godot 4.3-beta2)

Steps to reproduce

  1. Open Blender
  2. Model a big block (like 20x20x8 meters)
  3. Model a wall with an opening in the middle (like 30x10, with the opening like 1x2)
  4. Import both models into Godot
  5. Enable occlusion culling and bake occluders
  6. Look at the big block through the opening in the wall, so that the wall edges aren't visible in the viewport, but the opening touches the left or right edge of the screen (or even a corner).
  7. At a certain combination of camera position and rotation the big block will be culled while still very much visible through the opening in the wall.

Minimal reproduction project (MRP)

Run the game to see an animated demo.

MRP.zip

lawnjelly commented 1 month ago

The problem is the AABB is incorrect for the red box. If I set a custom AABB it works.

(Not sure where the responsibility lies for creating the AABB in 4.x, so leave for others to investigate.)

clayjohn commented 1 month ago

Running the MRP locally, it seems like this is also a self-occlusion problem. The red and blue boxes are getting occluded by their own baked occluders. Setting the red and blue boxes to invisible and re-baking solves the problem as well.

So likely some sort of precision issue that makes it so baked occluders are improperly occluding the object they were baked from. The issue also goes away when removing the wall in the centre of the scene. So there is some interaction between the angle of view, the size of the gap, and the AABB of the source mesh