Tool to convert static meshes to hierarchical instanced static meshes

Hey, quick 2 questions

  1. I want to make a tool which converts selected static meshes inside blueprint to hierarhical instanced static mesh and removes static meshes I tried every kind of blueprint utility I could find, but with no success, you have any tips / guidance how to do that? (Photo 1)

  2. I Managed to do something similiar I have blueprint utility widget it takes selected actor and search for all static meshes and convert them to HISM, first it look for HISM which matches Static mesh compoent with Mesh and materials then add instance if cant find match it creates new HISM, problem is when I have HISM with few instances and I wan
    t to add another instances it crashes here: (Photo 2)

The editor already does this

Hey, thanks for your answer, I tried it but it broke actor, that actor has many Static meshes, hierarchical instanced static meshes, skeletal meshes etc. You know where I could find source code for that tool ?

1 Like

To be clear, if these meshes are in a blueprint, then you can instance them from inside the blueprint.

The tool is only for meshes in the level ( map ).

The code is in the editor, if you get the source code for the engine, you have it.

1 Like

Where I can find it inside blueprint ?

I have source code for engine but I have no clue where to look for that tool

1 Like

If the BP already contains all the meshes you would need to add a HISM component, then add an instance for each static mesh component you have, and destroy them as you go.

It would make much more sense to construct the whole thing ‘procedurally’. So, rather than stacking lots of mesh components inside the blueprint, you use the construction script to add them as instances to the HISM ( it will be the only component to start with ).

This demo uses the right concept, but you would need to adjust it to your needs

1 Like

Problem is that the artists made a mess inside a blueprints, we have like 100+ BP of buildings they were adding static meshes with props so its easier for them to move it around (There were a bug where you couldn’t move single instance of HISM so easily) and now we have mess in all BP ( some components are static meshes, some are HISM’s) I wanted to make a tool which could easily convert that SM to HISM’s for organizations purpose

I Managed to do blueprint utility which takes selected actor and convert all static mesh components to hisms but there are bugs with it (photo 2 at beggining of post) and it would be super handy to add menu action like in (photo 1 at beggining of post) but I guess it will be tough, its possible to make utlity blueprint which takes selected components inside blueprint ? For now I know how to loop on every component inside bp and I would love to skip some components without setting tags or other stuff so it would be easier for artists to use it

1 Like

And its important to do it on blueprint assets not actors because we spawn buildings at runtime (its city builder game )

1 Like

If you end up having too many problems, rdBPtools on the marketplace can do that.

2 Likes

Looks very promising, if I dont find a way on my own I will give it a try :slight_smile:

1 Like

I hate to say it, but I think it might not help performance, and might even make it worse :joy:

It would be worth taking a good example BP and making an instanced version by hand.

Then try putting the BP version all over the map, vs, the HISM BP and compare performance. Because, for example, the instancing is only within the BP, not over the whole map.

Also, if you really want to take this route, it might be better to use ISM rather than HISM. HISM has several limitations, such as culling and LODding in chunks, which ISM does not. These don’t matter with things like foliage, the main use, but might give surprising results with buildings.

Later when we place a building into a world we have one manager which takes all HISM’s from building and put them all in one place so for example 10 copies of same building will be put in same HISM’s we decided for HISM’s because we need distance culling for some props

1 Like

Nice idea. But if you’re spawning ( as you said ), there will be a very big hitch when you start the level.

ISMs cull better than HISMs. HISMs cull in batches, which can look weird.

I would really recommend testing before you spend a long time going down one route or another :+1:

Only when we load levels we can have hitch but we have loading screen to cover it up, ISM’s have distance culling? I tought they are only culled by frustrum and occlusion, and in our game we have “bird view” is would be handy to have distance culling too for some props

I think you’re right :slight_smile:

I managed to solve it, you need BlueprintEditorModule and inside FBlueprintEditor class you can get selected components

To solve second problem, crashes when you are trying to add instance to HISM which already have x instances, I cache all instances in HISM then I remove HISM and add new HISM with all instances in one call