Using Instanced Meshes doesn't reduce draw calls
epic工程师的回答:
Instanced meshes will reduce the draw call overhead on the CPU but will not reduce the GPU cost. In fact the GPU time can increase when using instancing. Allow me to get a little technical for a moment:
This process has to do with the limitations of the CPU vs. GPU and how the API (OpenGL or DirectX) tries to maximize this limitation through batching. Instancing being a special case of batching. With a scene rendered with many small or simple objects each with only a few triangles, the performance is entirely CPU-bound by the API; the GPU has no ability to increase it. More precisely, "the processing time on the CPU for the draw call is greater than the amount of time the GPU takes to actually draw the mesh, so the GPU is starved." [Moeller, Real Time Rendering, 708]. So Batching attempts to allow the CPU to combine a number of objects into a single API call. In the case of Instancing it is the one mesh and the number of times you are drawing with a separate data structure for holding information about each separate mesh.
From a Rendering Engineerer:
"On meshes and material IDs, let me present a hypothetical situation to try to explain the situation more clearly. Let's say you have a mesh that has three materials: wood, chrome, and leather. Now let's say you place 100 of these meshes in your level. Ignoring other passes (shadow, depth only), this will result in 300 draw calls: one per-ID, per-instance. You can see this by looking at the section counts in the primitive stats window.
First thing to keep in mind: some draw calls are more expensive than others. The renderer sorts by material. So in this hypothetical scene we will draw the 100 wood elements first, the 100 chrome elements next, and the 100 leather elements last. Once we draw a wood element, the cost of drawing another wood element is not so high because we are rendering using the same shader and with mostly the same textures. But once we switch materials to draw the chrome we incur a high cost. That's why the renderer sorts by material.
Compare that situation to another scene where you have the same mesh instanced 100 times but each mesh has its own unique material. The scene is still 300 draw calls but the renderer incurs the material switch cost for every draw call. Instancing a mesh provides performance benefits even if the total number of draw calls does not reflect that"
To really see the performance boost in using Instances bring up the Stat UNIT and watch the DRAW versus GPU (CPU vGPU) and notice when you instance a mesh the CPU time remains fairly consistent depending on the additional information you are wanting to pass to each instance, while the GPU will increase. All of these numbers are still dependent on the size of your mesh and the type of material setup and the ultimate limitations of your CPU and GPU.
Thank You
Eric Ketchum
相关推荐
藏经阁-腾讯手游性能优化之路 本文档总结了腾讯手游性能优化之路,涵盖了手游市场现状、性能优化方法、自动化测试、数据采集和分析、客户端性能测试、Unity游戏自动化框架等多方面的知识点。 一、手游市场现状 * ...
文档还指出了一些性能上的问题与分析,例如过高的draw call数量、大量的面数以及复杂的材质和粒子效果。解决这些问题通常需要深入分析瓶颈,然后使用特定的优化技术来提升性能。优化策略通常包括查找瓶颈并针对性地...
10. **优化与性能**:最后,教程可能会涉及到性能优化技巧,如减少Draw Call、使用LOD系统、内存管理等,以确保游戏在不同设备上流畅运行。 这个“Ue教程.zip”压缩包很可能包含了以上所有或部分知识点的视频教程、...
10. **优化技巧**:学习性能优化技术,如减少draw call,优化内存使用,提高游戏运行效率。 通过这个项目,开发者不仅可以掌握虚幻引擎的基本用法,还能深入理解游戏开发的核心概念,同时提升C++编程技能。在实践中...
6. **性能优化**:实例化可以极大地提高效率,因为它减少了Draw Call的数量。然而,过多的实例可能会导致内存压力。因此,在实际应用中,可能需要考虑使用LOD(级别细节)系统或分批处理实例。 总结,通过ShaderLab...