Is It Feasible to Render 100 Million Triangles Using C++ Soft Rasterization with Nanite Logic?

<span>"[The Nanite Popularization Plan] Handcrafted Nanite"</span> has been launched, and the era where everyone can use Nanite is approaching.

The following have been brought in to help:

  • • Single-threaded C++ left-handed coordinate system soft rasterization rendering pipeline
  • • OpenGL 1.0
  • • Direct3D 9
  • • Direct3D 12

It’s the end of the year!<span> Takumi! It's time to change jobs!</span>

C++ Rendering 100 Million Polygons

As the saying goes, if one does not strive in their old age, what is the point of growing old? Now is the perfect time to work hard; if you do well, you can enjoy the company of young models, but if you do poorly, you might suffer a stroke and die suddenly. I feel like my ideas are getting more extreme; this morning I woke up and doubled the performance of yesterday’s single-threaded program, achieving 100 fps:

Is It Feasible to Render 100 Million Triangles Using C++ Soft Rasterization with Nanite Logic?

Yesterday, the soft rasterization renderer rendered Nanite at 55 fps:

Is It Feasible to Render 100 Million Triangles Using C++ Soft Rasterization with Nanite Logic?

This step mainly involved adding backface culling logic, which is implemented in the following lines of code:

void RenderTriangle(...)
    ...
    vector4 faceNormalWS = inFaceNormal * inModelMatrix;
    ...
    vsOut[0].mPositionWS = inCluster->mPositions[in1] * inModelMatrix;
    vector4 NV = vsOut[0].mPositionWS - inConstantBuffer->mCameraWorldPosition;
    if (dot(faceNormalWS, NV) > 0.0f) {
        return;
    }
    ...

Next, I want to utilize all 16 of my logical cores, for instance, initializing 32 wavefronts and concurrently rendering Nanite in soft rasterization. After all, the compute shader on NVIDIA cards can handle 32 wavefronts concurrently, so let’s get to it.

The reason for this thought is that others are rendering over 100 million triangles with Nanite, while I am only rendering 56,000 triangles, rounding it to 50,000. The original model has about 56,000 triangles, and the actual number of clusters in the original model is 454, with each cluster containing approximately 125 triangles. Therefore, the actual number of triangles in the original model is about: 454 x 125 = 56,750 triangles. After processing with Nanite, the final total number of triangles in the NaniteMesh is: 932 x 125 = 116,500 triangles, with the extra triangles being the LOD constructed by the Nanite system through its hierarchical system.

So let’s stick with 56,000 for a more objective view. I then duplicated this model: 10,000,000 / 56,000 = 1786, and placed them in the scene to see the fps, which will tell us if soft rasterization can render 100 million triangles.

Alright, the multithreading setup isn’t complete yet, and arranging so many models is also a big issue, so let’s focus on this task for today!

Nanite Progress Bar

  • C++ soft rasterization implementation (completed for students, feasible)
  • Android OpenGL ES2.0 version (packaged into apk for real device operation) (completed for students, feasible)
  • • Android OpenGL ES3.1 version (packaged into apk for real device operation)
  • • Android Vulkan version
  • • Windows Vulkan version
  • Windows OpenGL 1.x version (completed for students, feasible)
  • • Windows OpenGL 2.x version
  • • Windows OpenGL 3.x version
  • • Windows OpenGL 4.3 version
  • • Windows OpenGL 4.6 version
  • • iOS Metal version
  • • MacOS Metal version
  • • WebGPU version
  • • WebGL version
  • Windows Direct3D 9 version (completed for students, feasible)
  • • Windows Direct3D 10 version
  • • Windows Direct3D 11 version
  • Windows Direct3D 12 version (tutorial from scratch has been released)

The code for the completed explorations mentioned above<span> has been</span> placed in:

  • <span>The official "Game Engine Development Practice"</span> Nanite module
  • <span>The official "Handcrafted Nanite with D3D"</span> course reference materials

We know that Nanite is a vast concept that cannot be explained clearly in a short time, so we have reserved enough capacity on the official website for students to explore freely. If the explanation of the <span>core logic of Nanite</span> is to help the world understand how to use Nanite, then “<span>Game Engine Development Practice</span>” is to make you someone others can never reach!

References

  • • “<span>Game Engine Development Practice</span>” 2025 expansion pack “Lumen<span>Reverse Engineering</span>

Postscript

  • • Graphics Technology Meditation Group: 460926233
  • • Official WeChat account: battlefireedu
  • • Official website: https://edu.battlefire.cn
  • • Bilibili account: Donghan Academy official channel

Leave a Comment