Download

Static Mesh Instancing

HI,

Can someone explain how to use, and if there is a way to instance a static mesh in UE4? I, other modeling apps, it save on memory and other resources. I have dug around on the internet a bit. But have not found a clear answer.

Thanks

1 Like

UE4 already does it, when you use something from the Content Browser more than once it will keep only one in memory.

Oh. Ok. Thanks. So, If I drag a chair from the content browser, place it in the scene, and then begin to copy that around it is automatically instanced?

Yes, though that still increases the number of draw calls

instanced static mesh actors in UE4 are different to the instances of static meshes in a scene. while it is true that they are kept in memory by default, they do, as darthviper says, still increase the number of draw calls.
for a project I’m working on I was using modular assets to create a small town and I had a small-ish scene that crawled to 12fps because the number of assets were hitting 12K draw calls. by moving everything in to a blueprint and making it out of ‘instanced static mesh’ actors in the blueprint I was able to bring this down to ~200 draw calls, increase my FPS to 60+
there’s a pluggin you might want to start out with, called ‘ramas victory pluggin’ that you may find useful. instanced static mesh actors in blueprints are a pain to work with and his tool seems to work quite well to just copy-paste everything in.

Thanks for the link to the Ramas Victory Plugin. Looks like is not available for 4.12 yet. I will keep my on it.

Aaron

I am looking into using Rama’s “Victory Plugin” for static mesh instancing and I am seriously wondering why this workflow (turning mesh placements in the World Outliner into blueprint instance placements and back) is not a default part of UE4 interaction. Can somebody explain that?

Also, as far as I understand Rama’s plug-in for this is now in his “Victory Ed Engine” and the “Victory Plugin” is essentially a collection of random blueprint nodes: A new, community-hosted Unreal Engine Wiki - Announcements and Releases - Unreal Engine Forums

Not everything works better from that, which is why it’s not the default.

It’s to do with a whole bunch of other things. this is a specific-use scenario and you’re using a general-use workflow.

You can just open a blueprint, add some instanced static mesh actors, and start adding instances to the array (this is what i do), all rama’s pluggin does is convert the world-position of assets in to this array to make it easier.

the issues with ISM actors is they all have to share the same object properties. if you want to change the material for one instance of a mesh, you have to make a new ISM actor and place an instance of the new one with the changed material, etc.
also, if you have LODs, they will all pop in/out at the same time based on the screen-space size of the entire array. for a per-object LOD you have to use heirachical instanced static mesh actors, which cant be edited by hand in the blueprint viewport. what i do for this is just make the array as ISM actors and then copy-paste the array over to HISM actors.
if you want to talk more about this, I stream my work most days over on twitch. come chat and I’ll help you out.

  • Thank you, but I am actually aware of all of this. I specifically wonder how to

efficiently.
For example, I have hundreds of (hand-placed) rocks (with LODs) in the World Outliner and I want to make HISMs out of them in order to reduce draw-calls. As far as I understand, the only way to do this quickly would be with Rama’s plug-in. Is that correct, or is there a default interaction that allows me to do this in UE4 without the plug-in?
(I would imagine I can do it with Blueprints via the “Get all actors of class” node, but I don’t know how to filter that array for the rocks I care about and I want to keep overhead as low as possible. Even if I were to do the whole thing on construction only, I would imagine it would at least increase my loading time.)

  • I prefer to keep it to the Forums so everyone has access to the info in the future, and I am pretty sure we are in different time zones anyways, so it would probably be difficult for me to catch your stream.

Ah, you’re in the same boat I am then.
For work, most of my time is spent duplicating the instances i want. i have blueprints with literally like 100 ISM actors with HISM actor duplicates, and some of the actors there have like… 700+instances. all hand-done. AFAIK, rama’s thing is the only way to do it nicely. trust me, 100-200 hand-placed rocks is literally nothing :stuck_out_tongue: thats a few hours work tops.
To put it in perspective, my modular building set im working with is 7mx7mx6m, and I’ve made factories that are 1Kmx500m+
doing it by hand is the only way outside of the pluggin rama made.

The thing is: In theory the stuff that Rama’s plug-in does is very easy to achieve. When you Ctrl+C static meshes in your scene and Ctrl+V that into a text file (let’s call it “placements.txt”), you get a list of transforms with a bunch of meta info. Now, on the HISM and ISM blueprint node you can paste transforms into the Instances elements to get instance placements. Theoretically all you have to do is make a relatively simple string processor to convert “placements.txt” into a format that the HISM and ISM nodes understand. If somebody could make the conversion a mini program, we would not need Rama’s plug-in. - Actually I am not even sure why I try to avoid using his plug-in. I think it is not a very good idea to rely on non-commercial plug-ins developed by one person, because support might end at any point. On the other hand Rama seems to be quite active, so I am not too worried.
7cbc1a27d58fcc09602e410402bed8dc53dd8218.png

I think UE4 needs an enhancement that allows users to just copy a bunch of placements in the level and paste them directly into a transform list like the one on the HISM node.

>describes how ramas pluggin works
>wants someone to make something identical to ramas pluggin
>doesnt want to use ramas pluggin

just saying :stuck_out_tongue:

But you could even just use an online tool like textmechanic.com to manually modify the copy-paste info from the level in to something the HISM array understands.

  • True true. I still would like to have an alternative to using a plug-in and will look at the textmechanic software. Thanks for that!

There is a text format for placement of stuff. There’s even a maxscript around these forums that lets you paste locations directly from 3DS Max. It pastes as static meshes though.

Anyway, here’s a simple BP I used for modular elements:

Thank you, this is very interesting.
This shows how placements can be attached to a HISM node interactively. Now it’s just a matter of reading out placements of a particular static mesh type from the scene.
(Then the BP could read out the placements, delete/deactivate the objects in the scene, attach the placements to a HISM node and you would have the functionality of Rama’s plug-in without having to install a plug-in. Right? - Aside the possible overhead for the BP, of course.)

Here’s the script:

It was made by someone here in the forums, I just modified a bit because it was rounding off rotations and messing up vertex snapping.

After using the script, all you have to do is CTRL+V in the unreal engine window and it will fill the scene. But you have to have the meshes already in UE.

Also, if you’re placing a single object, you can paste it in the mesh location transform and it will work as well.

That’s the script to get 3DS Max placements into UE4, right? (If so, that is certainly very useful and it would work great with a slightly different workflow, but it is not exactly what I was actually looking for.)

I am still trying to wrap my head around whole HLOD and HISM thing :confused: but I am in the same boat - I am an artist / designer and currently I am working on an organic scene where I don’t need to make a wall comprised of 100 instances (which is what @Elrinion’s BP for, or so it seems).

I would much rather make a scene using traditional workflow (nothing procedural, everything placed into scene by hand), then select duplicates of the same static mesh (or bound it by volume to improve automation) and turn them into hierarchically instanced HLOD static meshes.

@RyanB explained some of the stuff here: HLOD Folder under my Content>Maps folder [What is HLOD?] - Rendering - Unreal Engine Forums but it’s a bit over my head right now :o

For anyone who lands here in the future, this page might help you out.

Specifically it’s a script that allows you to manually place empty transforms in the level editor, and the script loops through those transforms and feeds them to a HISM for spawning instances at hand placed locations. You might be able to implement that algorithm in your own blueprints as well. Neat!

1 Like