-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Mapblock mesh LOD #16594
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
Draft
Handmade9485
wants to merge
126
commits into
luanti-org:master
Choose a base branch
from
Handmade9485:convex_hull
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Mapblock mesh LOD #16594
+647
−78
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…on the minimap color
sfan5
reviewed
Oct 29, 2025
sfan5
reviewed
Nov 3, 2025
…nvex_hull # Conflicts: # client/shaders/nodes_shader/opengl_fragment.glsl # src/client/mapblock_mesh.h
…o rely on github workflows
this didnt look too egregious in my testing but is worth looking further into
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
@ Client rendering
Feature ✨
PRs that add or enhance a feature
Performance
Roadmap: supported by core dev
PR not adhering to the roadmap, yet some core dev decided to take care of it
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR draft adds basic LOD mesh generation.
It works by changing how a mapblock mesh is generated depending on the distance to the player. Only certain node types are included in LOD generation, so for example plantlikes are not rendered. The allowed nodes are then used for a greedy mesher to further reduce vertex counts. The less detailed the LOD, the fewer node samples are used for mesh generation.
After a certain threshold, the mesh is rendered with only one material, without a texture to reduce material swaps.
The threshold after which LODs should be used, the rate at which LOD level increases, and the threshold for textureless mesh generation are configurable in the settings.
The LOD mesh generation is significantly faster than regular mesh generation, especially on less detailed meshes. The meshes also use considerably less RAM, since their vertex count is a lot smaller. The LODs also yield a small performance improvement in my testing.
Ive gotten quite a bit in over my head with this one, so any feedback or maybe even advice is greatly appreciated.
To do
This PR is a Work in Progress
To do maybe
Add a new kind of vertex. Since the LODs are always exactly grid aligned and are always cuboid, they wouldnt need 9 f32 fields for their position, size, and normal per vertex. The textureless meshes also wouldnt need any uv information.Pre-generate multiple LODs at once, to easily swap between them when a player moves closer to or further away from a certain chunk or uses the zoom function.Persist the meshes client side, so they can be loaded immediately upon loading a world. (Might be impossible due to mesh chunk size possibly changing or when playing on servers.)How to test
These are not very detailed instructions since there are so many different combinations of nodes and settings.