Question about instanced static meshes

Hi!

I’m a bit confused about the use of instanced static mesh. In my case I have a level with a lot of static mesh (huge amount). These meshes are placed into my level as static mesh actor, not as blueprint so I can’t set them as instanced static meshes. Should I create a blueprint with a instanced static mesh component and populate again my level?? it will increase the performance??

Thanks

in my own way, i think i wold create an actor that would be named as instanced static mesh spawner…
then inside, i would add components for the type of mesh that would be inside the instanced static mesh component…
ifi remember it correctly, each kind of static mesh type you want must have it’s own instanced static mesh component…
so, if you have a square and a circle, you need 2 instanced static mesh component… not one…

then as long as i know the world location i want to spawn in.
i just have to tell the spawner what type of static mesh i want to be spawned and the location to spawn in…

note: if i explained some things wrong, please correct me, as i’m just explaining what i had in mind…

and yeah, using instances of static mesh would definitely increase alot of performance…

:slight_smile: good luck

If there are hundreds or thousands of the same mesh rendered in the same view (depending on the camera angle, etc), converting these to ‘instanced’ meshes, will reduce time spent in draw calls (but not time spent on the GPU or Game thread)

With console command ‘stat unit’ check if Draw is actually the problem.

In a scene where you don’t have too many draw calls, you may have stats like this:
Frame: 30ms
Game: 29ms
Draw: 2ms
GPU: 29ms

‘Frame’ is overall time it takes for one frame, Game, Draw and GPU execute in parallel.

Unreal engine executes most of the code in Game thread, and quite a bit in Render Thread (measured in Draw metric). Time that video card spends is displayed under GPU. (while Game is preparing next frame, GPU is displaying previous)

Switch from lots of static meshes, to few instanced static meshes will reduce draw calls, and should improve Draw stat. However, if Draw time is not the same as GPU and Game, then you are not bottlenecking there.

Note that if you have 10k trees in the scene, but only 300 of them in the view, occlusion culling also happens on the Render Thread (displayed under Draw). If you switch this setup to one instanced mesh with 10k instances, draw could be much faster (one call with a list of 10k transforms, instead of 300 models with vertices, indices, vertex colors, especially if these models are complex), but GPU will then have to handle all triangles from all instances, before they’re discarded because they’re out of view. You could potentially slow down GPU time.

Without instancing, Render Thread will only send 300 draw calls for those 300 trees that are rendered, and GPU will only have to process those vertices/triangles. GPU does triangle and pixel culling later on, but switch from normal meshes to instanced meshes will always increase GPU time while reducing Draw time. Sometimes this pays off, other times it doesn’t.

It’s great for clumps of foliage made up of the same model, in relatively small area, which is what engine already does for you if you’re using Foliage as a way of distributing your meshes. What you paint as ‘foliage’ doesn’t have to be a tree or bush… it can be anything.

Thanks guys! and sorry for my delayed reply!

@yanzco : My static meshes are already in the scene. I mean, they are not instanced at runtime so I don’t need a spawner.

@xulture: Thank you very much for your explanation. Fix me if i’m wrong…in my case I have a lot of static meshes but they only have “render cost” when they are inside camera frustum but instanced meshes have to be computed even when the camera is looking to other point. So for me should work better let the static mesh actors in the level like they are right now.

About foliage, I was testing it but my project is about a kind of urban race and some of my meshes are people (public) with a specific pose to fit in a specific place, so foliage is not an option.

Again thanks both for your advices. Finally seems that instanced meshes does not works for me.

Bye

Sort-of correct. When you have bunch of instanced static meshes, bounding box of all of them is considered for view culling, and when it overlaps, all of them are sent to the video card.

If you have 4 instanced actors, each with 10k instances, and you’re looking at only one of them, only that one (and its 10k copies) are rendered. If your view includes all four, then all 40k instances are rendered.

Ahhh ok! thanks for the clarification!

Regards!

I haven’t read up on them since I couldn’t really find any use at the time, but wouldnt creating a Bluetility to replace all instance of be a better approach?