-
-
Notifications
You must be signed in to change notification settings - Fork 22k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix to occlusion culling where all math is based on Euclidean distance. #98257
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally, it works as expected. The overocclusion issue from #94210 no longer occurs, yet the level of occlusion remains similar as seen in the Overdraw debug draw mode.
However, in the MRP from #94210, no occlusion culling seems to occur with an orthogonal camera in the editor (using the Overdraw debug draw mode for a preview). This occurs in both master
and this PR, so the issue is likely somewhere else:
Either way, this resolves the original issue, so it could be merged now already.
Although I was initially thinking #97712 would be simpler, having had a look at that PR last night, there are a number of gotchas with that method that are unresolved. This PR on the other hand ends up being simpler than expected, and sidesteps these gotchas, so on balance I now would be thinking of trying this method first. Of course we will only know snags after some trial in the wild. |
Looks good to me. I also tested locally and can confirm that the overocclusion issues in the MRP are fixed and there is no noticeable increase in false negatives (from eyeballing). Let's go ahead with this PR and see if things improve in the wild. |
Thank you! And great work everyone! |
Alternative solution to #94210. Main discussion can be found here #97712
The occlusion culler uses a point to compare with the depth mipmap to determine if an object is occluded or not. The occlusion culler currently chooses the point with the shortest Euclidean distance to the camera. While not entirely inaccurate, it can drift when compared to the actual closest point to the camera in terms of depth.
This inaccuracy increases when an object's AABB is skewed (relative to the camera perspective) and partially occluded by other objects, as seen in the MRP in #94210 and the 2D example below.
There were two possible solutions to this problem, and this PR implements the first solution.
Possible solutions:
This PR converts the depthmap used for occlusion culling to euclidean distance. Additionally logic is then added for an orthogonal camera.
bugsquad edit: Fixes #94210