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 radial distance for making LOD decisions. #67307

Merged
merged 1 commit into from
Oct 13, 2022

Conversation

TechnoPorg
Copy link
Contributor

Makes LOD distances use radial distance, whereas previously, only the depth forward from the camera was used as the distance. This means that unnecessarily high LOD levels were used for objects located to the side of the camera.

Fixes #54885.

Previously, only forward basis distance from the camera was used.
This means that unnecessarily high LOD levels were used for objects located to the side of the camera.
The distance from the camera origin is now used, independently of direction.
@TechnoPorg TechnoPorg requested a review from a team as a code owner October 12, 2022 14:07
@Calinou Calinou added this to the 4.0 milestone Oct 12, 2022
@Calinou
Copy link
Member

Calinou commented Oct 12, 2022

Remember to check the behavior when using an orthogonal camera. Most importantly, we need to make sure overly aggressive LOD levels are not forced when using an orthogonal camera.

@fire
Copy link
Member

fire commented Oct 12, 2022

I tested on the models I had and it looks ok, but I didn't test the error case #54885

Maybe someone can make a video.

@clayjohn
Copy link
Member

Remember to check the behavior when using an orthogonal camera. Most importantly, we need to make sure overly aggressive LOD levels are not forced when using an orthogonal camera.

Indeed, the changes look great for perspective camera, but we may need to have different behaviour for orthogonal cameras like we do for calculating distance for sorting purposes. For reference, this is what we do for object sorting

if (p_cam_orthogonal) {
	depth = near_plane.distance_to(origin);
} else {
	depth = p_cam_transform.origin.distance_to(origin);
}

@TechnoPorg
Copy link
Contributor Author

Remember to check the behavior when using an orthogonal camera. Most importantly, we need to make sure overly aggressive LOD levels are not forced when using an orthogonal camera.

Orthogonal distance calculation already has different behaviour, as a result of #57419. I'm less certain about how this will work with a camera in frustum mode, though.

Copy link
Member

@clayjohn clayjohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Thanks for pointing out that this gets ignored when using orthogonal. As for frustum mode, we don't alter any of our other distance calculations yet, so I am fine leaving this as is.

@akien-mga akien-mga merged commit f2bd389 into godotengine:master Oct 13, 2022
@akien-mga
Copy link
Member

Thanks!

@fire
Copy link
Member

fire commented Oct 16, 2022

Might be a regression? #67479

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vulkan: LOD seems to be flawed, distance seems based on forward basis distance
5 participants