I am working on a large project in a large team, and I had a question about efficiency regarding draw calls and instancing.
Previously, all modeled geometry in the project was unique, so, even if _House1 and _House19 contained the same “Wood bookshelf with 30 red books” mesh, that was actually being stored and rendered as unique geometry everywhere it existed (and using the same materials - wood for the shelf, and a red book texture for all the books). Of course, this means that, aside from offset from the origin and rotation, the same data for “Wood bookshelf with 30 red books” was being stored in multiple places needlessly. (larger filesize)
Since this was storing too much identical data, an effort is now being put forth project-wide to optimize. However, I have a question about how that’s being done. What’s happening is this: “Empty wood bookshelf” (1 material) was derived from the old bookshelf mesh, and “Red book” (an individual book, 1 material) was derived from the old bookshelf mesh also, meaning the 30 books in each bookshelf are now also individual (and instanced) meshes.
Is this a huge problem? Should the books, all which have the same material, be combined into one mesh, so that they only have the cost of 1 draw call? Or does UE4 automatically recognize that the books all have the same material, and efficiently draw them all at the same time anyways?
UE4 will not batch/instance automatically, so you will need to combine the books into a single mesh. What does happen automatically is that if you use a mesh from the content browser multiple times in a level then it will only get stored into memory once. But–if the mesh is very simple/low poly then it’s better to combine meshes than to use more draw calls. The number of polygons that can be handled is usually very high, and draw calls have a big impact on performance.
It is possible to batch/instance things in the engine, but you have to do that manually using Blueprints.
If we wanted to have some of the bookshelves have a unique amount of books, i.e., ten bookshelves have 10 books, ten bookshelves have 20 books, and ten bookshelves have 30 books – then it would technically be larger filesize to save those as three (Shelf10books, Shelf20books, Shelf30books) as unique meshes, however, it would be “worth it” to do so, as opposed to having each book be an individual mesh?
Individual books = slightly less filesize, but significantly more draw calls (1 draw call per individual book)
Grouped sets = slightly larger filesize, but significantly less draw calls
Yes, since the books are low-poly, the amount of memory to save 30 of them is insignificant, so it’s better to have lower draw calls than to have less memory.