I have 6 identical characters in my scene (all the same, except animation sequence plays with slight offset for each of those). Is it possible to create 6 instances of that character to reduce overhead ? If so, how would I do that? Thanks!
While on the subject of instancing stuff, can I also create instances for particle systems ?
I don’t think you can instance skeletal meshes at all, I know you can do it with static meshes definitely.
Instancing in UE4 refers to combining meshes that use the same material so that it reduces draw calls. In Unity it’s called batching. Otherwise, you can save memory since if you use an object more than once it will keep only one in memory. Usually engines can handle high poly counts pretty well so in many cases it’s better to reduce the number of draw calls than to reduce the amount of memory.
This is how instancing work underhood. You have single mesh and you tell gpu to draw this same mesh multiple times. Each instance use InstanceID at vertex shader to grab it’s own transform matrix. No data duplication happen in anyplace.
Right, that’s how instancing is normally done, I don’t know why they call it instancing here in UE4 when in reality it’s batching. By default if you use an asset more than once it will keep only one in memory, but each of those copies is a draw call so if you want to keep the number of draw calls low then you can use the Instance Static Mesh Blueprint which will batch them together, but that stores them all in memory.
That’s something different, that’s the part of the engine that automatically takes care of static meshes so that it keeps only one in memory if the mesh is reused. If you want to reduce draw calls then you can use the Instanced Static Mesh Blueprint which will combine them together but doesn’t have the advantage of saving memory.
Placement of the same static mesh multiple times as different actors. Each has a slight memory overhead if they have unique lightmaps, or vertex color. But the geometry is in memory only once. It’s still multiple draw calls, though.
You merge the actors, in which case the memory footprint will increase as you are creating a new and bigger mesh. You will also reduce draw calls to 1.
You “batch” your actors with blueprint using InstancedStaticMeshComponent.
Your memory stays like in example 1. pretty much, but you only use one draw call. There are certain disadvantages such as not being able to paint vertex color, having different settings for each individual instance as well as that the entire “batch” will swap LOD and cull as if it was one single object.
You “batch” your actors with blueprint using HierarchicalInstancedStaticMeshComponent.
Similar to 3. except LOD and culling is handled at a per-instance level. There is a slight overhead in CPU I would guess? as doing that is not free. You still have one draw call, though.
Going back to the question, I don’t think there is a way to “batch” skeletal meshes in UE4 as far as I know.
This is awesome. When I try to open the uproject. It says “NextRTS could not be complied. Try rebuilding from source manaually.” I searched on how to do this but cant find anything. How can this been done?
I am looking at the repository trying to do what stag beetle has done here, but I am having some trouble.
engine_patch.7z is not a patch, it includes the full modified files. That being the case I am having great difficulty determining what was changed to enable these vertex animations. What version of Unreal did these files originate from before you modified them? Was it even an official release version or were you working of some odd commit/branch on the repository? The .uproject file only shows the gibberish generated from your custom engine build instead of a version number. I am looking at diffs between these files and what is in Unreal v4.17.1 and I can’t tell if the changes were added for this or if it was part of an unrelated update, because a lot of it looks unrelated. Some of the changes make me wonder if all or part of this functionality has been added to the engine since stag beetle wrote this.
I still need to look into this more, but I am also hoping to apply this to the Hierarchical Instanced Static Mesh Component so I can take advantage of it’s grouped LODs as well (assuming I am correctly understanding the difference between the two). Would this even work though? Since Vertex Animations are based on the vertices does this not make them incompatible with LODs? Is it even possible to make this work with Hierarchical Instanced Static Mesh Components?
Also, I would like to not use a modified engine. I presume it would be trivial to include a renamed and modified InstancedStaticMeshComponent as a part of a single project and not need to rebuild the entire engine (I’ve never built the engine from source before and our lab setup is such that maintaining a modified engine across all the machines is not a feasible option).