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

Function to separate disconnected pieces of geometry #570

Closed
myaaaaaaaaa opened this issue Jul 2, 2023 · 4 comments
Closed

Function to separate disconnected pieces of geometry #570

myaaaaaaaaa opened this issue Jul 2, 2023 · 4 comments

Comments

@myaaaaaaaaa
Copy link

myaaaaaaaaa commented Jul 2, 2023

1685292966

This would be useful for mesh shading pipelines, as it would allow each piece to be assigned to its own task shader, and allow finer granularity for traditionally per-object operations such as culling and LODs. This is much simpler than Nanite's approach to fine-grained crack-free LOD transitions, which requires headache-inducing algorithms in order to build and traverse a DAG of meshlets.

Engines would presumably generate LODs for every piece after they are separated, and then split every piece's LODs into meshlets.

See the following comment for more details on task shaders and pieces of geometry: godotengine/godot-proposals#6822 (comment)

To maximize compatibility with non-mesh shading pipelines, it should probably sort a supplied index buffer (remap table?) and return an array of {index_offset; index_count} pairs to represent distinct pieces, so that pieces (and their LODs) can act as an optional structure that references standard index buffers.

@zeux
Copy link
Owner

zeux commented Jul 8, 2023

Why is connectivity important? For example, given a tree model with separate leaves, this function would likely have to report a very large number of connected clusters, each being a single leaf, as the leaves would not be connected to each other and the trunk would have a separate material.

Normally mesh shading pipelines cull per object and then per cluster (meshlet). The second level of granularity is finer than any sort of cluster grouping. If a higher level cluster grouping is desired, I'm wondering if it would be sufficient to simply treat each consecutive group of meshlets of a desired size (eg every 64 meshlets) output by meshopt_buildMeshlets as a group, if the goal is to reduce the culling cost.

Overall I don't fully understand the ask here.

@myaaaaaaaaa
Copy link
Author

myaaaaaaaaa commented Jul 9, 2023

Normally mesh shading pipelines cull per object and then per cluster (meshlet). The second level of granularity is finer than any sort of cluster grouping.

For context, I'm investigating an alternative approach where sections of a scene would be aggregated into a single large model (say, a city block), which would then be drawn by using mesh shading as essentially a hardware-accelerated 4-level HLOD:

  • 1 draw call per (large) object (as with the traditional pipeline)
  • 1 task shader per connected cluster
  • 1 mesh shader per meshlet
  • 1 rasterizer unit per triangle

In such an arrangement, connected clusters would be analogous to what would normally be treated as objects during level design.

This has the benefit that it can be retrofitted to a traditional pipeline more easily and is less cumbersome to set up than traditional HLODs. It would also make such scenes easier to exchange between DCC applications, as the object hierarchy would be less cluttered.

Why is connectivity important?

...

If a higher level cluster grouping is desired, I'm wondering if it would be sufficient to simply treat each consecutive group of meshlets of a desired size (eg every 64 meshlets) output by meshopt_buildMeshlets as a group, if the goal is to reduce the culling cost.

Connected clusters are the finest granularity at which LOD swaps can be guaranteed to be crack-free. While there are technically ways to reach even finer granularity using something like Nanite's DAG of meshlets, this would require far more engineering resources and be much harder to generalize across users of meshoptimizer.

For example, given a tree model with separate leaves, this function would likely have to report a very large number of connected clusters, each being a single leaf, as the leaves would not be connected to each other and the trunk would have a separate material.

Thanks, I hadn't considered this - perhaps it would be prudent to provide an option to set a lower limit to the number of triangles/vertices in a cluster, so that multiple tiny connected clusters that can fit into a single meshlet can still be drawn together.

@zeux
Copy link
Owner

zeux commented Jul 9, 2023

Connected clusters are the finest granularity at which LOD swaps can be guaranteed to be crack-free.

Ah, I see. So the goal is to increase the granularity of LOD from the single mesh to a smaller unit without having to synchronize LOD transitions between pieces. That makes sense.

@myaaaaaaaaa
Copy link
Author

The need for this has gone down significantly on my side, but thank you for the consideration nonetheless!

@myaaaaaaaaa myaaaaaaaaa closed this as not planned Won't fix, can't repro, duplicate, stale Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants