Reduce drawcalls between actors

Can you show one of your BPs in more detail? I made a BP, which contains two meshes ( one inside the other ), both having 6 materials. I have no hit, even with 100 on the screen.

What’s your fps? Are you using dynamic lights?

I’m not sure I understood your description of your game well, but I understand that you just want to put a lot of objects on screen at once, right?

The UE youtube channel recently released a video on how to do that with Niagara. This one here.

I don’t know if this will help you or not, but I thought I would mention it just in case it would. :slight_smile:

Those mats look fine…

Here’s another example ( I’m trying to find what you’re doing ):

I know it looks the same, but all the vessels are now spawned in the construction script:

I noticed you’re spawning actors, I’m spawning components…

EDIT: Nope, did it with actors, no difference.

Hello everyone! I am really in need of a solution, this block in development haunts my dreams, in many of my projects it reoccurs and I nearly gave up!

Imagine a game about a laboratory where you have to navigate a player in a topdown view, between cupboards of ingredients, mixing and managing a lot of objects.I tried to have a cupboard class that would spawn 2top and 2bottom items randomly, then generate a maze with those as walls. Basically a storage-maze.

Sadly as expected my drawcalls went up insanely, since it draws for every cupboard individually, and for every ingredient object in those cupboards. So even though if in the best case 1 type of shelf texture and 1 ingredient texture is in the map, it draws the same two textures 500+ times. How would you make Unreal batch drawcall them, so objects (from the same class) with the same mesh/texture combo feed off the same drawcall? Is it even possible in Unreal? Or in any engine?

How does Overcooked handle all those tables around the map, that can even move around, have funcionality and so on? How does Planet Coaster handle a building with hundreds of components? I can’t rely on LOD-s because my camera is always at a fixed distance, like in Overcooked, but even more zoomed in so it doesn’t have to load even more at the screen.

I tried to work with Instanced static meshes, but I need the meshes to attach to hands, roll on the ground with gravity, have collisions etc. And under “drawcall reducing threads” I’ve always found the “merge meshes” answer which doesnt help in my case, because the items and cupboards move independently, and are randomly generated. And I can’t use instanced meshes with materials that have opacity. I heard that UE4 added auto instancing, but yet again it doesn’t seem to work. Do I have to set something? What would be your solution? Are you just not meant to have a lot of actors at the scene at once?

Here are some of my tests with ISM-es and auto instancing that didn’t work.

Thanks in advance for your help!!

Thanks for your answer! All of those are separate actors of your blueprint placed in the scene? That’s insane, the drawcalls are so low! How?
Here are screenshots from my project. The cupboards are sometimes generated, sometimes I make a preset maze by placing them in the scene, and the items are randomly generated potion types, spawned on their shelves (now its only one type of potion to show even 2 materials cause a problem).

The potions have 1 mesh 1 mat, and the cupboard has 1 mesh 1 mat. Thats all. On my ingame screenshot I had 500 drawcalls. But your screenshot seems to have the same setup as mine, or the “red gem” screenshot earlier. What’s the difference?

Thank you! I’ll watch it for sure!

I plan on using PBR textures with normal maps and roughness maps. The ones in my screenshots just use a single colour.

I don’t use anything heavy, I get max fps if the meshes are turned off and the code runs. In my original post I tried to do the same thing as you did with the boxes. Make a simple BP with only a mesh and place a hundred objects in the scene. It’s the red gem (first screenshot) one. Still draws hundreds. My light is actually stationary, is that dynamic? It’s the same one you get when you make a new level. I can see in your last screenshot that you are really just using one shelf in a blueptin as a static mesh component and placing it a lot. I’m starting to get my hopes up. Thanks for helping we might find a solution!

Are the materials simple? Just albedo?

I’ve got a lot of cupboards here:

I have the wood material and two different bottle materials. Still get 120 fps…

It must be something else you’re doing… Anything on tick, per chance?..

I’m gonna flake out now, but I think we can sort it…

Thank you so much I’m sooo blessed that you are helping. And seeing that you don’t have the problem gives me so much hope! I had physical headaches because of this. Nearly all my programming and models are ready to go, but as soon as I started making a level with basic models it all fell apart and I started to panic. Thanks again! See you later!

I made a new project and imported the meshes and took a screenshot of everything that I did:

I created a BP for the shelf, added a mesh and set the cupboard as the static mesh. Created a simple material for it, and just to check I used the master material, not an instance of it on the mesh. (later checked with mat instance, no difference). Dragged 100 of them on the level and checked the empty shelf drawcalls. It wasnt good.

Then I created a potion BP, and programmed the shelf to spawn 4 potions on the shelves at Beginplay. I created a blue material instance for it. The results were the same as in my other projects. Huge drawcalls, low fps.

I guess you made a new project to test my problem out, and I did as well but failed. I didn’t tick, change, or set anyting in the starter scene or in the blueprints when I made them. Just the ones I screenshotted. Is it something basic I don’t change when creating them? Maybe its a setting in the Project Settings or in a component?

I have to go now, but will come back later. Can you show all the code for the BP?

Thanks and see you later! I don’t really know what else to show you nothing else is related. As you saw earlier I recreated a new project and programmed the minimum like you did with your test, only mine still had the problem. Did you do anything else, when you did your test? Tick in magical boxes, or something in the project settings? Take a look at the last screenshot I did yesterday, its basically step by step, but no sign of auto instancing. Would there be a way you could send a similar simple project that’s working for you so I can see if my drawcalls are different on my PC? But it’s not important if you don’t want to or if it’s forbidden here.

I tried to use the command
r.MeshDrawCommands.DynamicInstancing 0
To see if anything takes effect and in my red gem scene the 200 drawcalls (which was high in my eyes compared to ISM-s where its 10 and truly instanced) went up to 380. Turned it back with:
r.MeshDrawCommands.DynamicInstancing 1
And it dropped down to 200. But surely it can’t be the lowest, you had 30 drawcalls with more materials and higher poly models. That seemed reasonable.
Also, I’m using the lights added in by the sample level unchanged which is static not stationary, because I wan’t shadows on my actors. When I change it to static it drops to 37, which would be ideal, but the whole project loses its shadows.

Also this thread is very similar:

And it worked for a guy and didn’t for the other as well. No solutions though,
An other good example

I would try changing the vessels to components rather than separate actors ( see my earlier script ). I did notice a hit when using actors. ( back later )

I’m just wondering a couple of things now:

  1. How many tris is that shelf model? It should be < 50.

  2. What’s your machine spec?

It’s ~40 but it’s not the final model, and the gems in my first performance test were lowpoly as well.
I have an AMD FX 8320 (8core) processor and a Geforce GTX 760 graphics card. 8Gb ram, running from ssd. I didn’t have much problem with running high end stuff.

First of all thank you for sticking with my question and not giving up. I’m so grateful! It’s been haunting me and stopping me achieveing anything.

I recreated your 6 material cube scene to see if I would get the same 30 drawcalls. I recorded the whole process as fast as I could (3mins) so you can see what I might be doing wrong, and what the difference is between our projects. Spoiler: I got 700+ drawcalls

I created a blank project, with maximum quality and no starter content. Disabled auto exposure and hit record. You can even see the light settings as it’s selected at the start. There must be something basic or hidden I’m not doing.

Ok, I’ve made a demo project. It has 100 shelves with 24 bottles on each one and runs flat out. See how you do:

https://drive.google.com/file/d/1DDc7rGX-WwwoptZJt-oVJquA-40EDMLZ/view?usp=sharing

Oh wow thank you so much! Just so I don’t keep you waiting some updates:
Your project runs exactly like on your computer! It’s perfect! Even with actors, even if I spawn random type of vessels on those shelves. I’ll look into what’s different between my projects with further testing. I’m so excited! I’ll keep you updated!