-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Implement visibility range and dependencies #48847
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.
Looks really good on a quick review. You'll need to do a search and replace to replace all instances of "hysteriesis" with "hysteresis"
Are you using the LOD metric that is used by mesh optimizer? |
Oops, will do :P
No, AFAIK the mesh LOD metric uses the edge lengths and this system has to work on all GeometryInstance3D types. Also, a simple distance check with hysteresis should work just fine for this kind of HLOD. |
Does this visibility range system take the camera FOV into account? I wonder how we can keep using distance ranges while supporting wider/narrower camera FOVs. (Switching to screen coverage metrics would solve this problem automatically, but computing screen coverage has a cost.) If we want to keep ranges, we could assume that the "default" camera FOV is 75 and use a greater distance multiplier when the FOV is lower (and lower multiplier when the FOV is higher). Edit: Visibility dependencies aren't FOV-aware, but it can be done by the user if needed. See https://chat.godotengine.org/channel/rendering?msg=ZZE5g87XzQPxpyi5u. |
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.
Looks good to me!
I am thinking that as much as it pains me, we should probably change it to a system where the parent has a visibility override over the children and not backwards, else usability will be poor. |
I updated the PR with the following changes:
|
aaf4e31
to
0da3930
Compare
Pushed the latest version with a new way to define visibility dependencies and fixes for all the mentioned issues. |
Looks fantastic, really great job with this! |
I would wait for #48207 to be merged before merging this one. I will take care of the merge conflicts then |
This commit adds the following properties to GeometryInstance3D: `visibility_range_begin`, `visibility_range_begin_margin`, `visibility_range_end`, `visibility_range_end_margin`. Together they define a range in which the GeometryInstance3D will be visible from the camera, taking hysteresis into account for state changes. A begin or end value of 0 will be ignored, so the visibility range can be open-ended in both directions. This commit also adds the `visibility_parent` property to 'Node3D'. Which defines the visibility parents of the node and its subtree (until another parent is defined). Visual instances with a visibility parent will only be visible when the parent, and all of its ancestors recursively, are hidden because they are closer to the camera than their respective `visibility_range_begin` thresholds. Combining visibility ranges and visibility parents users can set-up a quick HLOD system that shows high detail meshes when close (i.e buildings, trees) and merged low detail meshes for far away groups (i.e. cities, woods).
@akien-mga Rebased! |
Thanks! |
This commit adds the following properties to GeometryInstance3D:
visibility_range_begin
,visibility_range_begin_margin
,visibility_range_end
,visibility_range_end_margin
.Together they define a range in which the GeometryInstance3D will be visible from the camera,
taking hysteresis into account for state changes. A begin or end value of 0 will be ignored,
so the visibility range can be open-ended in both directions.
This commit also adds the
visibility_parent
property to 'Node3D'.Which defines the visibility parents of the node and its subtree (until
another parent is defined).
Visual instances with a visibility parent will only be visible when the parent, and all of its
ancestors recursively, are hidden because they are closer to the camera than their respective
visibility_range_begin
thresholds.Combining visibility ranges and visibility parents users can set-up a quick HLOD system
that shows high detail meshes when close (i.e buildings, trees) and merged low detail meshes
for far away groups (i.e. cities, woods).
This is a simple example "city":
visdep.mp4
And this is a stress test with 50k of such "cities" (900k meshes in total):
visdep_fly.mp4
Bugsquad edit: This closes godotengine/godot-proposals#692.