How to instance animated skeletal actors ?

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 ?

All this is for Android platform.

The engine will already manage assets so that if you reuse something it will store it once in memory. If you want to batch assets to reduce draw calls then that’s not an option in UE4.

Oh :frowning:

Doesn’t UE4 instance geometry at all? Kinda odd considering other engine do that to reduce number of drawcalls to minimum for identical geometry :confused:

You can using Blueprints. You don’t want something that just does it automatically because you’d want the choice whether you want to save memory or save draw calls

So, instancing animated skeletal actors (along with static actors) is possible with BP ?

If so, where can I find a tutorial about the subject ?

Not sure why would you not save memory with instancing :confused:

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.

Instancing does not refer to combining. It’s mean Instanced draw call. It’s does not increase memory consumption. It might increase polycount because not all instances are culled separately.

I don’t think that’s true, if you combine them into a single draw call then it can’t store one in memory anymore

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.

Where in the source code that dublication is happening?

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.

I also believe you are mistaken.

There are four methods afaik:

  1. 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.

  2. 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.

  3. 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.

  4. 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.

Since Galaxy S6 has 3Gb of memory, I am guessing batching might do more bad than good (depending on polycount). Gotta test it.

hi, bump this thread.
I am preparing a small tech demo for Unreal Open Day.
it uses vertex animation to animate static mesh ,and use instanced static mesh component to render.
binary here

project :

need to patch the engine (override the instance random ) .

Performance is great:D, but I am looking for solutions to rebuild normal, current normal is calculated based on ddx/ddy from world position , and result in complete flat shading.

From the link,seems only way is to modify hlsl shader in Engine, what 's the suggested way to do it ?
Any suggestion is welcome!:slight_smile:

This is actualy a pretty wicked test case. Thakn you for this.

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).