Instanced static mesh rendering vs static batching ? How do the engine handle it?

Hi !

I’d be curious to know more about how the engine handle and render instanced static meshes (e.g. for foliage, maybe particles ?). If anyone has knowledge about it, I think it could improve assets and material setup.

Here is what I assume so far:

  • let’s say I have a static mesh of a tree, composed of a trunk and branches (one material), and leaves (another material). So adding a tree to my scene would add two draw calls to the rendering loop (one per material).

  • If I add other trees to the scene using a simple drag&drop, it should still be two draw calls as the engine will most likely build a static batch with all trunks, and another one containing all leaves as they all share the same material.

  • If I set a foliage type using my tree mesh, and use the foliage brush to “paint” trees in my scene, what I assume is that it would use GPU instancing instead of static batching, and this would still be two draw calls (?)

  • Now let’s say I have another variation of the same tree, i.e. different mesh but sharing same trunk and leaves materials with the original tree. How does the engine render both different species ? I guess it renders all instances of tree #1 using GPU instancing, then same for tree #2 which make 4 draw calls.

  • Or does it try to combine trunk #1 and trunk #2, leaves #1 and leaves #2 in some way ?

TLDR my questions are:

  • Are my assumptions close to what the engine do, i.e. using static batching for normal static meshes sharing same materials, and GPU instancing for foliage ?
    - Is it worth trying to reduce number of different materials for foliage meshes ?

Thanks for insights!