Skip to content
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

Use direction between camera origin and AABB center to calculate minimum support for LOD selection #92290

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

clayjohn
Copy link
Member

@clayjohn clayjohn commented May 23, 2024

Fixes: #81995
Fixes: #76436

Supersedes #82000

Builds on #92287 but introduces riskier changes.

This PR simplifies and improves the LOD selection logic by calculating the depth as the distance to the closest AABB corner.

The old logic used the camera z direction to calculate the min and max supports. This was flawed as it meant that rotating the camera could drastically change which supports were chosen and (as pointed out in #81995) if the camera looked slightly past an AABB, it could cause the supports to change and then jump LOD levels.

This change fixes that by basing the support on the camera's origin point instead of view direction. This ensures that the lod_distance never changes based on rotation.

A second improvement is the removal of support_max. It used to be used for two things:

  1. Calculating whether we are inside the AABB
  2. it was possibly the closest support point

Now, support_min is guaranteed to be the closest support point and we check if the point is inside the AABB manually, so there is no reason to keep support_max.

I also moved the entire calculation outside the loop since everything depends on the instance. It doesn't need to be recalculated for the surface.

Opening as a draft for now as I want to test this with more MRPs from #57416 as I suspect the combination of #92287 and this will fix a number of issues.

@Calinou Calinou added this to the 4.x milestone May 23, 2024
@akien-mga akien-mga changed the title Lod fixes Use direction between camera origin and AABB center to calculate minimum support for LOD selection May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants