mirror of
https://github.com/openharmony/third_party_meshoptimizer.git
synced 2026-07-19 12:03:07 -04:00
demo: Add usage examples for meshopt_optimizeMeshlet
Mention this in README as a recommended post-processing step and add to meshlet processing pipeline for coverage.
This commit is contained in:
@@ -330,6 +330,12 @@ meshlets.resize(meshlet_count);
|
||||
|
||||
However depending on the application other strategies of storing the data can be useful; for example, `meshlet_vertices` serves as indices into the original vertex buffer but it might be worthwhile to generate a mini vertex buffer for each meshlet to remove the extra indirection when accessing vertex data, or it might be desirable to compress vertex data as vertices in each meshlet are likely to be very spatially coherent.
|
||||
|
||||
For optimal performance, it is recommended to further optimize each meshlet in isolation for better triangle and vertex locality by calling `meshopt_optimizeMeshlet` on vertex and index data like so:
|
||||
|
||||
```c++
|
||||
meshopt_optimizeMeshlet(&meshlet_vertices[m.vertex_offset], &meshlet_triangles[m.triangle_offset], m.triangle_count, m.vertex_count);
|
||||
```
|
||||
|
||||
After generating the meshlet data, it's also possible to generate extra data for each meshlet that can be saved and used at runtime to perform cluster culling, where each meshlet can be discarded if it's guaranteed to be invisible. To generate the data, `meshlet_computeMeshletBounds` can be used:
|
||||
|
||||
```c++
|
||||
|
||||
@@ -866,6 +866,9 @@ void meshlets(const Mesh& mesh, bool scan)
|
||||
else
|
||||
meshlets.resize(meshopt_buildMeshlets(&meshlets[0], &meshlet_vertices[0], &meshlet_triangles[0], &mesh.indices[0], mesh.indices.size(), &mesh.vertices[0].px, mesh.vertices.size(), sizeof(Vertex), max_vertices, max_triangles, cone_weight));
|
||||
|
||||
for (size_t i = 0; i < meshlets.size(); ++i)
|
||||
meshopt_optimizeMeshlet(&meshlet_vertices[meshlets[i].vertex_offset], &meshlet_triangles[meshlets[i].triangle_offset], meshlets[i].triangle_count, meshlets[i].vertex_count);
|
||||
|
||||
if (meshlets.size())
|
||||
{
|
||||
const meshopt_Meshlet& last = meshlets.back();
|
||||
|
||||
Reference in New Issue
Block a user