-
-
Notifications
You must be signed in to change notification settings - Fork 104
Description
Describe the project you are working on
A large open world game with a visibility range of 25 km.
Describe the problem or limitation you are having in your project
I have large patches (2×2 km) of trees, which are created using MeshInstance3D. At some distance, I replace these by billboard impostors, which look fine when they are at least 500 m away. I would like to use the built-in visibility_range_begin and visibility_range_end options.
However, the distance at which the fade happens is computed to the center of the AABB (see #102799). This makes sense if the object is small. For a 2×2 km patch of trees, however, the camera can be close to a corner of the patch, yet still 1.4 km away from the AABB center, so the entire patch is still rendered as impostors. I'd want to switch to full tree models in this case as well.
In godotengine/godot#68243, another issue was raised: if the AABBs between different LODs are not identical (more precisely: don't have the same center), then there will be distances at which neither or both LODs are visible. Here, the expectation seems to have been that the distance is computed from the object's origin rather than its AABB center. (The docs mistakenly state "origin" as well, for which I've sent godotengine/godot-docs#11511.)
Describe the feature / enhancement and how it helps to overcome the problem or limitation
If the distance were computed to the closest point on the AABB, rather than the AABB center, this would be resolved. To preserve backwards compatibility, this would have to be opt-in.
To deal with the case of differing AABBs: if the object's origin is near the center of the AABB, then it's fine to use the origin instead.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Add an enum option visibility_range_distance_to, with these values:
GeometryInstance3D.AABB_CENTER(default): current behaviour, base visibility on distance to AABB center.GeometryInstance3D.AABB_NEAREST: base visibility on distance to nearest point on AABB.GeometryInstance3D.ORIGIN: ignore AABB, base visibility on distance to object origin.
This would go under Visibility Range in the inspector.
If this enhancement will not be used often, can it be worked around with a few lines of script?
Yes, it's possible to control visibility manually from a script. For this many chunks however, it's fairly performance-intensive to do it in GDScript.
For cases where computing distance to the origin is acceptable, a workaround is to use visibility_parent or setting custom AABBs so they're all the same.
Is there a reason why this should be core and not an add-on in the asset library?
Visibility range is in core.