About this document
When bringing large scenes into real-time environments a large amount of manual work is demanded for the material setup and application to the individual objects. This is not only a large amount of manual work but also creates a large number of draw calls. In this case, the example-scene makes up over 83k polygons and 212 draw calls.
What are Draw Calls
A Draw call consists of the CPU instructing the graphics card to draw something on the screen. Every time the graphics card is instructed to draw something on the screen, an overhead consisting of state changes is generated on the GPU.
A single draw call may only take a fraction in overall render time, but having too many draw calls will add up and can result in idle times where the graphics card is waiting to be instructed to start a new draw call doing nothing in between.
Therefore the ideal situation is to get as many state changes as possible and batch them together into a single draw call to reduce the points where CPU and graphics card have to synchronize.
Material Merging allows users to take one or more objects with multiple materials and merge all materials together into a single one. This process creates a single new material with baked textures that can be used to recreate the materials in any renderer. Existing input textures are baked together into a single texture atlas with UVs being repacked to optimize the UV layout. This allows for drastic draw call reductions.
Material Merging the city scene reduces the draw call count from the original 212 to 98 draw calls due to the individual 98 objects sharing the single new material.
The different importance metrics will measure the specific attribute of the faces/meshes and will increase or decrease the size of the geometry accordingly in the resulting texture atlas.
- UV Importance measures the occupied UV space of the faces/meshes and will increase the weights accordingly, a single face occupying the whole UV space will be relatively bigger compared to a face that is very small in the UV space.
- Geometric Importance measures the world space area of the geometry and will increase the weights accordingly, bigger meshes will occupy more UV space in the resulting atlas.
- Texture Importance measures the texture sizes of the input meshes and will increase the weights accordingly, meshes with higher resolution textures will occupy more UV space.
- Visual Importance measures the visibility of meshes in the scene and will increase the weights accordingly, hidden faces and meshes will occupy less UV space.
Taking it one step further
To take the draw call reduction even further we can utilize InstaLOD's 'Mesh Tool Kit' (MTK).
The Mesh Tool Kit is equipped with a large number of features to prepare and fix meshes such as 'Remove Degenerate Faces', 'Conform Normals', 'Fill Holes' and many more.
In this case, the feature 'Combine Meshes' is used to combine all 98 objects into a single one, ending up with one object using one material, resulting in a single draw call.
When combining this workflow with the proper use of mesh operations, this city block with 212 draw calls and 83k polygons can be reduced to less than 800 polygons using a single draw call.
The final scene was created using the following operations:
- Building - AABB Imposter
- Walls - Billboard Imposter
- Ground with assets - Remesh
For more information on 'Imposterizing' please read this article on 'Finding the right imposter'.