<p>First, to preface: the reason it's hard to find details about these hierarchical cluster culling systems because they are a still emerging field, at the very cutting edge of real-time rendering development. Only a handful of games/engines have successfully shipped something like this, and mostly not source-available (UE5 being a recent exception). It is an area of very active development and research, so there are no standard algorithms; everyone is experimenting and doing it differently. That said, I'll try to give a picture of what this is all about and why people are excited about it. This is going to be kind of a brain dump, but I hope it's somewhat useful.</p>
<hr />
<p>First of all, why are mesh clusters important? Historically, real-time rendering engines have done things like frustum and occlusion culling, as well as LOD selection and draws, on an object-by-object basis. What an &quot;object&quot; is here, is determined by the engine but would often correspond to a single authored model from a 3D content creation app, or to a scene graph node, or to higher level game logic (e.g. an entity with its own behavior such as a character or vehicle). In other words, object boundaries are not primarily determined by rendering considerations, but by other things entirely.</p>
<p>As games have increased in geometric complexity, the amount of vertices/triangles in an &quot;object&quot; (whatever that means in a given game) have tended to increase. For example, player characters in AAA games might easily have hundreds of thousands of triangles. And we can only make LOD or culling decisions at the object level. If any part of an object is visible, we have to draw the whole thing, which might not be very efficient. When we want to switch LODs, we have to switch it for the whole object at once, which tends to cause visible popping since there are generally only a few discrete LODs stored for any given mesh.</p>
<p>Another effect of increasing geometric complexity is that triangles are typically denser on screen, covering ≲10 pixels each, and often down to just ~1 pixel each for very dense meshes such as AAA characters. Such dense geometry exacerbates various inefficiencies in GPU rasterizers, such that over-rendering (i.e. drawing more triangles than you need to) becomes a more significant performance problem than it was in the past. This is why Nanite uses a compute-based software rasterizer for extremely dense meshes (and falls back to regular hardware rasterization for larger triangles or tricky corner cases, such as triangles that cross the near plane).</p>
<p>Mesh clusters, also known as meshlets, are a way to break down these object-sized meshes into more manageable pieces. The meshlets are a roughly fixed geometry size, such as 64–128 vertices, no matter how big the object they come from. Then we can make rendering decisions per meshlet instead of per object. At a minimum, we can cull per meshlet, which enables us to do things like only render the visible parts of a large object. With some more work we can also make LOD decisions per meshlet, so that we only render parts of an object at high detail that are close enough to need high detail, and farther away parts can be at a lower detail. This also gives us much more fine-grained LOD control; we can transition a mesh from one LOD to another a few meshlets at a time, rather than all at once, reducing the problem of visible pops. To do this we need a way of ensuring that we can have meshlets at different LODs without cracks between them, which is tricky to do; Nanite has a clever approach to this.</p>
<p>Meshlets are also relevant for rendering using <a href="https://developer.nvidia.com/blog/introduction-turing-mesh-shaders/" rel="nofollow noreferrer">mesh shaders</a>, which is a separate topic, although it dovetails well with meshlet-based culling/LOD.</p>
<p>As far as algorithms for building meshlets go: there are lots of ways to do it, but generally you start a meshlet with an arbitrary triangle, then iteratively try to add other triangles that share as many vertices as possible with the triangles already in the meshlet. You might also incorporate some scoring for candidate triangles based on how much they increase the size of the bounding box (favoring smaller boxes) or how much their normals deviate from those already in the meshlet (favoring similar normals). Once you've got enough vertices/triangles to fill the meshlet, you mark them as used, and you start again with a new unmarked triangle. The <a href="https://github.com/zeux/meshoptimizer#mesh-shading" rel="nofollow noreferrer">meshoptimizer</a> library includes a meshlet building algorithm, if you want to take a look at it.</p>
<p>Once you've grouped your triangles into meshlets, you might still have a lot of meshlets, so it can make sense to do the same thing again and group neighboring meshlets together into larger clusters, and so on again hierarchically, forming a tree. Nanite does something along these lines, but also builds simplified representations of each cluster (keeping the boundaries intact) in order to be able to switch LODs without cracks. See the &quot;Brief Analysis of Nanite&quot; article linked at the bottom for more details.</p>
<p>For the SDF-based apps like Dreams and Claybook, I think their &quot;clusters&quot; are just 4×4×4 bricks of SDF, and larger clusters are higher mip levels of the SDF, so that's much simpler to deal with.</p>
<p>For culling on the GPU: the basic idea is you run a compute shader over the list of meshlets (one thread per meshlet). It does the culling calculations (e.g. testing bounding box against frustum, testing normal cone against camera position to eliminate backfacing meshlets) and outputs the list of surviving meshlets into an append buffer. This list becomes the input to an indirect draw or indirect dispatch which renders the visible geometry. This is well-suited for the GPU because it's a massively parallel computation, and there can be a large number of meshlets in the scene.</p>
<p>In the case of a tree of clusters, you start at the root and walk down the tree. At each node you can make the decision to accept the whole node for rasterization (and stop traversal), or cull the whole node, or else recurse to the children. In a compute shader this can be implemented by issuing separate indirect dispatches for each level of the tree, with each level outputting a list of nodes to be processed in the next level. However, Nanite takes a different approach to this with what appears to be a single compute dispatch that uses a ring buffer (maybe?) of nodes to process, and the shaders keep running and popping off nodes to process until the whole thing is done. Nanite also does LOD selection during this phase, as higher levels in the tree represent more simplified LODs, and it stops descending a part of the tree when it reaches a node with low enough LOD error to render it (or if it reaches parts of the tree that are not streamed in at the moment - in which case it can also log a request for that node in another append buffer, to be read back and processed by the CPU streaming code later).</p>
<p>GPU occlusion culling is a pretty interesting algorithm, too. The basic idea is to use last frame's depth buffer as an approximate &quot;initial guess&quot; as to what surfaces are visible or occluded in the new frame, then fix up the errors (things initially marked as occluded that are actually visible) in a second pass. Alex Evans talked about this a bit in the HPG keynote you linked above. This doesn't actually require hierarchical cluster culling, but can be applied even for ordinary object-based culling on the GPU. Basically, while you're traversing your list/tree of meshlets to cull, if they pass the frustum and backfacing tests then you test their bounding box against the HiZ buffer (hierarchical representation of the last frame's Z-buffer - basically a mip chain that stores the min and max Z in each pixel). This is done using the last frame's camera and object transform for that node. If the bounding box is behind the HiZ buffer then that node is culled and traversal stops, but it also gets added to a separate list of occlusion-culled nodes to re-test later. You proceed to rendering all the nodes that passed this first culling pass, then build a new HiZ buffer from the current frame's depth buffer so far. Finally, you re-test all the occlusion-culled nodes against the new HiZ buffer, which lets you find all the ones that were mistakenly culled but are actually visible. Then you resume traversal etc as usual for those nodes, and draw them in a follow-up pass. This second pass usually contains a relatively small number of nodes, in areas where camera or object movement has created a &quot;disocclusion&quot; (a place where previously hidden geometry has been revealed). Finally, the HiZ buffer is updated again and goes forward to repeat the process in the next frame (as well as being potentially used for other purposes, like screen-space ray tracing for lighting).</p>
<hr />
<p>Further on Nanite specifically, here are some analyses made by third parties (not Epic-associated) looking at Nanite in RenderDoc and reading the source code:</p>
<ul>
<li><a href="http://www.elopezr.com/a-macro-view-of-nanite/" rel="nofollow noreferrer">A Macro View of Nanite</a></li>
<li><a href="https://www.notion.so/Brief-Analysis-of-Nanite-94be60f292434ba3ae62fa4bcf7d9379" rel="nofollow noreferrer">Brief Analysis of Nanite</a></li>
</ul>
<p>Since UE5 is source-available, you can go and look at the code for Nanite if you want. You have to register with Epic to join their GitHub organization, but then you should be able to access the following links (deep linked to the Nanite source directories within the UE5 GitHub):</p>
<ul>
<li><a href="https://github.com/EpicGames/UnrealEngine/tree/ue5-main/Engine/Source/Developer/NaniteBuilder" rel="nofollow noreferrer">Nanite data preprocessing</a></li>
<li><a href="https://github.com/EpicGames/UnrealEngine/tree/ue5-main/Engine/Source/Runtime/Renderer/Private/Nanite" rel="nofollow noreferrer">Nanite CPU rendering code</a></li>
<li><a href="https://github.com/EpicGames/UnrealEngine/tree/ue5-main/Engine/Shaders/Private/Nanite" rel="nofollow noreferrer">Nanite shader code</a></li>
</ul>
<p>Also, some of the Nanite (and Lumen) developers are scheduled to do talks at this summer's SIGGRAPH, where no doubt additional details and history will be discussed.</p>

CC BY-SA 4.0
2024-07-25T18:46:28.607Z
I want to make a pedantic but necessary disclaimer. UE5 is not open source. It has a multiplicity of legal requirements, such as not being allowed to share more than 30 LOCs on public channels.

You can inspect the source code if you agree to their licensing terms, but that;s not what Open-Source means. The technical term for UE's licensing is 'source-available'
Makogan
CC BY-SA 4.0
2024-07-27T14:03:57.573Z
I've seen that hierarchical z-buffer occlusion culling algorithm used in many places but is there a paper on it? I couldn't find one. Where/who does the technique come from?
Tom Clabault
CC BY-SA 4.0
2021-07-26T00:38:27.733Z
2024-07-25T18:46:59.213Z
2024-07-25T18:46:59.213Z
Nathan Reed
<p>I've seen several references to this and related concepts now but I can't find any hard details about these systems, and how they are implemented.</p>
<p>The earliest reference I can find is from the <a href="https://advances.realtimerendering.com/s2015/aaltonenhaar_siggraph2015_combined_final_footer_220dpi.pdf" rel="noreferrer">&quot;GPU-driven rendering pipelines&quot;</a> talk by Sebastian Altonen.</p>
<p><a href="https://i.sstatic.net/YrHgk.png" rel="noreferrer"><img src="https://i.sstatic.net/YrHgk.png" alt="enter image description here" /></a></p>
<p>But I was made aware of the topic from Nanite information that has surface recently, for example Brian Karis talks about it <a href="https://youtu.be/TMorJX3Nj6U?t=3592" rel="noreferrer">in the presentation here</a>, but not with many details:</p>
<p><a href="https://i.sstatic.net/0Mhg5.jpg" rel="noreferrer"><img src="https://i.sstatic.net/0Mhg5.jpg" alt="enter image description here" /></a></p>
<p>Alex Evans also talked about the concept a bit in his <a href="https://youtu.be/eGfX1iWzkh0?t=2686" rel="noreferrer">High Performance Graphics 2021 conference keynote</a>, but Dreams (which he worked on) doesn't use triangle meshes, it's a signed distance field system instead:</p>
<p><a href="https://i.sstatic.net/hZhLw.png" rel="noreferrer"><img src="https://i.sstatic.net/hZhLw.png" alt="enter image description here" /></a></p>
<p>To summarize what I think I understand:</p>
<p>Mesh vertices, or more generally the geometry representations you have, are apparently grouped in some form ( though I don't know by what algorithm that is done exactly ) into clusters, then culled on the GPU based on bounding volumes of those clusters.</p>
<p>Apparently this concept  is well suited for GPU-driven occlusion and frustum culling (why and how?), dynamic LOD (why and how?), and makes it possible to create hierarchical representations of meshes where you can pick the LOD to render not for the whole mesh, but based on single clusters
at rendering time (why and how?). Apparently, Nanite pushes this far enough that you can't see any transition between different LODs.</p>
<p>What algorithms are used here for generating these clusters, culling them (particularly occlusion culling), representing them hierarchically, and picking LODs from them?</p>

<rendering><geometry><gpu>
What are 'mesh clusters' / hierarchical cluster culling (with LOD?) / triangle cluster culling and how do they relate?
cg_guy420
# What are 'mesh clusters' / hierarchical cluster culling (with LOD?) / triangle cluster culling and how do they relate?

(Asked by: username_0 on 2021-07-19)

I've seen several references to this and related concepts now but I can't find any hard details about these systems, and how they are implemented.

The earliest reference I can find is from the ["GPU-driven rendering pipelines"](https://advances.realtimerendering.com/s2015/aaltonenhaar_siggraph2015_combined_final_footer_220dpi.pdf) talk by Sebastian Altonen.

[![enter image description here](https://i.sstatic.net/YrHgk.png)](https://i.sstatic.net/YrHgk.png)

But I was made aware of the topic from Nanite information that has surface recently, for example Brian Karis talks about it [in the presentation here](https://youtu.be/TMorJX3Nj6U?t=3592), but not with many details:

[![enter image description here](https://i.sstatic.net/0Mhg5.jpg)](https://i.sstatic.net/0Mhg5.jpg)

Alex Evans also talked about the concept a bit in his [High Performance Graphics 2021 conference keynote](https://youtu.be/eGfX1iWzkh0?t=2686), but Dreams (which he worked on) doesn't use triangle meshes, it's a signed distance field system instead:

[![enter image description here](https://i.sstatic.net/hZhLw.png)](https://i.sstatic.net/hZhLw.png)

To summarize what I think I understand:

Mesh vertices, or more generally the geometry representations you have, are apparently grouped in some form ( though I don't know by what algorithm that is done exactly ) into clusters, then culled on the GPU based on bounding volumes of those clusters.

Apparently this concept is well suited for GPU-driven occlusion and frustum culling (why and how?), dynamic LOD (why and how?), and makes it possible to create hierarchical representations of meshes where you can pick the LOD to render not for the whole mesh, but based on single clusters
at rendering time (why and how?). Apparently, Nanite pushes this far enough that you can't see any transition between different LODs.

What algorithms are used here for generating these clusters, culling them (particularly occlusion culling), representing them hierarchically, and picking LODs from them?

**Tags:** rendering, geometry, gpu


---

## 1 answers

### Answer by username_1 on 2021-07-26. Score: 12 | Accepted answer

First, to preface: the reason it's hard to find details about these hierarchical cluster culling systems because they are a still emerging field, at the very cutting edge of real-time rendering development. Only a handful of games/engines have successfully shipped something like this, and mostly not source-available (UE5 being a recent exception). It is an area of very active development and research, so there are no standard algorithms; everyone is experimenting and doing it differently. That said, I'll try to give a picture of what this is all about and why people are excited about it. This is going to be kind of a brain dump, but I hope it's somewhat useful.

---

First of all, why are mesh clusters important? Historically, real-time rendering engines have done things like frustum and occlusion culling, as well as LOD selection and draws, on an object-by-object basis. What an "object" is here, is determined by the engine but would often correspond to a single authored model from a 3D content creation app, or to a scene graph node, or to higher level game logic (e.g. an entity with its own behavior such as a character or vehicle). In other words, object boundaries are not primarily determined by rendering considerations, but by other things entirely.

As games have increased in geometric complexity, the amount of vertices/triangles in an "object" (whatever that means in a given game) have tended to increase. For example, player characters in AAA games might easily have hundreds of thousands of triangles. And we can only make LOD or culling decisions at the object level. If any part of an object is visible, we have to draw the whole thing, which might not be very efficient. When we want to switch LODs, we have to switch it for the whole object at once, which tends to cause visible popping since there are generally only a few discrete LODs stored for any given mesh.

Another effect of increasing geometric complexity is that triangles are typically denser on screen, covering ≲10 pixels each, and often down to just ~1 pixel each for very dense meshes such as AAA characters. Such dense geometry exacerbates various inefficiencies in GPU rasterizers, such that over-rendering (i.e. drawing more triangles than you need to) becomes a more significant performance problem than it was in the past. This is why Nanite uses a compute-based software rasterizer for extremely dense meshes (and falls back to regular hardware rasterization for larger triangles or tricky corner cases, such as triangles that cross the near plane).

Mesh clusters, also known as meshlets, are a way to break down these object-sized meshes into more manageable pieces. The meshlets are a roughly fixed geometry size, such as 64–128 vertices, no matter how big the object they come from. Then we can make rendering decisions per meshlet instead of per object. At a minimum, we can cull per meshlet, which enables us to do things like only render the visible parts of a large object. With some more work we can also make LOD decisions per meshlet, so that we only render parts of an object at high detail that are close enough to need high detail, and farther away parts can be at a lower detail. This also gives us much more fine-grained LOD control; we can transition a mesh from one LOD to another a few meshlets at a time, rather than all at once, reducing the problem of visible pops. To do this we need a way of ensuring that we can have meshlets at different LODs without cracks between them, which is tricky to do; Nanite has a clever approach to this.

Meshlets are also relevant for rendering using [mesh shaders](https://developer.nvidia.com/blog/introduction-turing-mesh-shaders/), which is a separate topic, although it dovetails well with meshlet-based culling/LOD.

As far as algorithms for building meshlets go: there are lots of ways to do it, but generally you start a meshlet with an arbitrary triangle, then iteratively try to add other triangles that share as many vertices as possible with the triangles already in the meshlet. You might also incorporate some scoring for candidate triangles based on how much they increase the size of the bounding box (favoring smaller boxes) or how much their normals deviate from those already in the meshlet (favoring similar normals). Once you've got enough vertices/triangles to fill the meshlet, you mark them as used, and you start again with a new unmarked triangle. The [meshoptimizer](https://github.com/zeux/meshoptimizer#mesh-shading) library includes a meshlet building algorithm, if you want to take a look at it.

Once you've grouped your triangles into meshlets, you might still have a lot of meshlets, so it can make sense to do the same thing again and group neighboring meshlets together into larger clusters, and so on again hierarchically, forming a tree. Nanite does something along these lines, but also builds simplified representations of each cluster (keeping the boundaries intact) in order to be able to switch LODs without cracks. See the "Brief Analysis of Nanite" article linked at the bottom for more details.

For the SDF-based apps like Dreams and Claybook, I think their "clusters" are just 4×4×4 bricks of SDF, and larger clusters are higher mip levels of the SDF, so that's much simpler to deal with.

For culling on the GPU: the basic idea is you run a compute shader over the list of meshlets (one thread per meshlet). It does the culling calculations (e.g. testing bounding box against frustum, testing normal cone against camera position to eliminate backfacing meshlets) and outputs the list of surviving meshlets into an append buffer. This list becomes the input to an indirect draw or indirect dispatch which renders the visible geometry. This is well-suited for the GPU because it's a massively parallel computation, and there can be a large number of meshlets in the scene.

In the case of a tree of clusters, you start at the root and walk down the tree. At each node you can make the decision to accept the whole node for rasterization (and stop traversal), or cull the whole node, or else recurse to the children. In a compute shader this can be implemented by issuing separate indirect dispatches for each level of the tree, with each level outputting a list of nodes to be processed in the next level. However, Nanite takes a different approach to this with what appears to be a single compute dispatch that uses a ring buffer (maybe?) of nodes to process, and the shaders keep running and popping off nodes to process until the whole thing is done. Nanite also does LOD selection during this phase, as higher levels in the tree represent more simplified LODs, and it stops descending a part of the tree when it reaches a node with low enough LOD error to render it (or if it reaches parts of the tree that are not streamed in at the moment - in which case it can also log a request for that node in another append buffer, to be read back and processed by the CPU streaming code later).

GPU occlusion culling is a pretty interesting algorithm, too. The basic idea is to use last frame's depth buffer as an approximate "initial guess" as to what surfaces are visible or occluded in the new frame, then fix up the errors (things initially marked as occluded that are actually visible) in a second pass. Alex Evans talked about this a bit in the HPG keynote you linked above. This doesn't actually require hierarchical cluster culling, but can be applied even for ordinary object-based culling on the GPU. Basically, while you're traversing your list/tree of meshlets to cull, if they pass the frustum and backfacing tests then you test their bounding box against the HiZ buffer (hierarchical representation of the last frame's Z-buffer - basically a mip chain that stores the min and max Z in each pixel). This is done using the last frame's camera and object transform for that node. If the bounding box is behind the HiZ buffer then that node is culled and traversal stops, but it also gets added to a separate list of occlusion-culled nodes to re-test later. You proceed to rendering all the nodes that passed this first culling pass, then build a new HiZ buffer from the current frame's depth buffer so far. Finally, you re-test all the occlusion-culled nodes against the new HiZ buffer, which lets you find all the ones that were mistakenly culled but are actually visible. Then you resume traversal etc as usual for those nodes, and draw them in a follow-up pass. This second pass usually contains a relatively small number of nodes, in areas where camera or object movement has created a "disocclusion" (a place where previously hidden geometry has been revealed). Finally, the HiZ buffer is updated again and goes forward to repeat the process in the next frame (as well as being potentially used for other purposes, like screen-space ray tracing for lighting).

---

Further on Nanite specifically, here are some analyses made by third parties (not Epic-associated) looking at Nanite in RenderDoc and reading the source code:

* [A Macro View of Nanite](http://www.elopezr.com/a-macro-view-of-nanite/)
* [Brief Analysis of Nanite](https://www.notion.so/Brief-Analysis-of-Nanite-94be60f292434ba3ae62fa4bcf7d9379)

Since UE5 is source-available, you can go and look at the code for Nanite if you want. You have to register with Epic to join their GitHub organization, but then you should be able to access the following links (deep linked to the Nanite source directories within the UE5 GitHub):

* [Nanite data preprocessing](https://github.com/EpicGames/UnrealEngine/tree/ue5-main/Engine/Source/Developer/NaniteBuilder)
* [Nanite CPU rendering code](https://github.com/EpicGames/UnrealEngine/tree/ue5-main/Engine/Source/Runtime/Renderer/Private/Nanite)
* [Nanite shader code](https://github.com/EpicGames/UnrealEngine/tree/ue5-main/Engine/Shaders/Private/Nanite)

Also, some of the Nanite (and Lumen) developers are scheduled to do talks at this summer's SIGGRAPH, where no doubt additional details and history will be discussed.

> **Comments:**
> **username_2**: I want to make a pedantic but necessary disclaimer. UE5 is not open source. It has a multiplicity of legal requirements, such as not being allowed to share more than 30 LOCs on public channels.  You can inspect the source code if you agree to their licensing terms, but that;s not what Open-Source means. The technical term for UE's licensing is 'source-available'  
> **username_3**: I've seen that hierarchical z-buffer occlusion culling algorithm used in many places but is there a paper on it? I couldn't find one. Where/who does the technique come from?  

---

