Author: https://twitter.com/ldl19691031
For the global pipeline of Unreal Engine 5, please check this: https://www.notion.so/Brief-Analysis-of-UE5-Rendering-Pipeline-feedcb9174aa4af2af936fbb02a9e390
In this article, I will write my own analysis of Nanite's source code. I only want to touch on the basic progress but not try to analyze the ideas behind the Nanite. This much beyond my skill. For the ideas behind Nanite, I recommend waiting for the official SIGGRAPH presentation.
This is the offical page of Nanite : https://docs.unrealengine.com/5.0/en-US/RenderingFeatures/Nanite/
Also, this is also anther good analysis of Nanite: http://www.elopezr.com/a-macro-view-of-nanite/
And the official Inside Unreal talk: https://www.youtube.com/watch?v=TMorJX3Nj6U
WARNING: I'm not a developer of Epic, and this article may contains mistakes and mislead you. This article focus on the details of Nanite's source so I recommend you to at least watch the videos of Inside Unreal's Nanite talk.
Nanite contains two parts: a pre-calculation system for preprocessing the meshes, generate mesh clusters and LODs; and a runtime system for loading and rendering.
So, the clusters will be the basic elements of a Nanite mesh. During the rendering, Nanite needs to:
Culling: both instance culling and primitive culling
Change the LOD: Nanite changes LOD level cluster-wise, which is different from many instance-wise LOD approaches. You can see only some of the clusters have changed:
Rendering: By hardware and software rasterizer ( I discussed a little in the rendering pipeline analysis)
In order to explain the mini-map of Nanite, I created this image:
First, Nanite generates a set of clusters based on the triangles, whichi becomes the leaf clusters.
Then, it will select a set of clusters as a new cluster group, and merge this group into a large cluster.(2 and 3)
Then, simplify this cluster, reduce the polygons but keep the boundary.(4)
Then, do a graph partition to split this large cluster into small parts. The parts are larger than the original clusters in (2)