In this lesson, you will learn how to optimize your frame rate by minimizing the communication overhead between your CPU and GPU caused by high draw calls and excessive geometry.
The Cost of Draw Calls
Every time the CPU tells the GPU to render an object, it issues a "draw call." If you have thousands of unique objects in a scene, the CPU spends all its time talking to the GPU rather than handling game logic. To minimize this, we focus on Instancing and Batching.
Harnessing Hardware Instancing
The most effective way to reduce draw calls for repetitive objects (like trees, rocks, or debris) is Hierarchical Instanced Static Meshes (HISM). Instead of the CPU sending a unique command for every single tree, it sends one command: "Render this mesh at these 500 different locations."
In your Level Editor, you can convert static meshes into an Instanced Static Mesh component. This allows the GPU to reuse the same geometry buffer for every instance, dropping your draw call count significantly.
Managing Primitive Counts
While Nanite handles high-poly geometry brilliantly, manual primitive management remains vital for non-Nanite assets. High primitive counts (triangle counts) place a heavy burden on the GPU's rasterizer.
- LODs (Level of Detail): Ensure every non-Nanite mesh has proper LOD chains. The goal is to reduce the triangle count significantly as the object moves further from the camera.
- Culling: Use
Max Draw Distancesettings on your actors. If an object is too small to be seen on screen, it shouldn't exist in the rendering pipeline. - Overdraw: Be mindful of "transparency stacking." Multiple layers of overlapping transparent materials (like particle smoke) create massive primitive overdraw, forcing the GPU to calculate the same pixel multiple times.
Practical Application
To visualize your efficiency, use the command stat rhi in the console. Look for "DrawPrimitiveCalls." If this number is in the thousands, your CPU is likely bottlenecking your rendering thread. By grouping similar objects into HISM components and aggressive LOD usage, you can keep this number manageable for your target platform.
Key Takeaway: To optimize rendering, prioritize reducing CPU-to-GPU communication via Instancing and ensure GPU efficiency by aggressively culling and simplifying geometry for distant objects.