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

clusterizer: Implement experimental triangle mask generator #553

Closed
wants to merge 5 commits into from

Conversation

zeux
Copy link
Owner

@zeux zeux commented Apr 26, 2023

This change computes triangle masks for each frustum slice, following "GPU-Driven Rendering Pipelines" from SIGGRAPH 2015.

The resulting masks can be used to quickly cull individual triangles, which only requires classifying the camera position in cube frustum face in the object space and selecting the appropriate set of triangle bits.

The masks can also be used to reject the entire clusters, or entire triangle groups, by comparing all of them to 0 in task shader and/or comparing each 32-triangle group to 0 in mesh shader before emitting that triangle group.

Note: this change is not fully tested, so it's not ready (may contain errors in sign/winding/etc.; also needs demo code cleanup)

This change computes triangle masks for each frustum slice, following
"GPU-Driven Rendering Pipelines" from SIGGRAPH 2015.

The resulting masks can be used to quickly cull individual triangles,
which only requires classifying the camera position in cube frustum face
in the object space and selecting the appropriate set of triangle bits.

The masks can also be used to reject the entire clusters, or entire
triangle groups, by comparing all of them to 0 in task shader and/or
comparing each 32-triangle group to 0 in mesh shader before emitting
that triangle group.
…asks

This provides a more uniform interface wrt meshopt_computeClusterBounds
and is convenient when the data isn't following the meshlet format (eg
consecutive chunks of index buffer are designated as clusters).
…neric

We now reuse less computation and as such masks take ~5% more time to
compute, but this code is a little harder to get wrong and will be
easier to extend to 24 regions.

Also adjust demo code to just perform classification on one side.
Also remove the main nested loop as a single loop is less error prone
and ~as efficient, and add a C++ template helper.

This change has been validated end-to-end on niagara renderer, and
results in ~10-15% triangles culled on average.
6 and 8 don't seem to be quite good enough; 24 is fairly reasonable.
This interface is very rigid so we will probably need to change this
so that meshopt only implements single-region classification.
@zeux
Copy link
Owner Author

zeux commented May 30, 2023

Per https://zeux.io/2023/04/28/triangle-backface-culling/ the results here are not that interesting so I'll leave this up for a bit but it looks unlikely that this will be merged.

@zeux zeux closed this Jun 5, 2023
@zeux zeux deleted the meshlet-masks branch June 5, 2023 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant