Trying to understand performance hits

I have built a hotel and I’m trying to figure out what is causing the performance issues. At first I thought it might be draw calls and or lighting. But the performance is hugely different depending on the number of actors/meshes in my level I load, even when they are not visible.

For instance: first-person POV in enclosed hall. No windows. Just the walls and doors can be seen. Ceiling lights are spots. If I remove everything else in the level and view this scene, I can run on epic preview. If I have all the actors in the level (unseen), I can barely run on low preview.

So what is happening with the unseen actors to cause the slow down?

Also (which may be relevant), as I pan the camera, the walls at the peripheral will sometimes be slow to render, briefly showing what is beyond.

Go to the lowest performance part of your scene. When you type the console command stat unit, what do each of the numbers roughly say?

Also, is this a generally bad performance over the entire duration of play? Or is it good sometimes but then gets sudden giant hitches or freezing?

Thank you for the quick response. I’ll try and get the stats soon, but to your question, with the level fully loaded (all actors), the performance is bad everywhere, even when editing a blueprint. So it won’t matter if I am in a hallway, or outside with all the floors and lights visible.

I have attached the stats of the exact same scene. Both set to high. One with all actors loaded into the level, the other one with most actors removed. I chose the hallway because the external actors should have no impact on this scene. But clearly do.

319300-stat-unit-high.jpg

alt text

319299-stat-unit-high-actors-removed.jpg

Yikes! You weren’t kidding.

Okay, so every single thing is red, and very red at that. I’m just going to pick a place to start, and see where it goes from there…

First of all, the GPU is the largest without the actors in it. …It is really difficult to get the GPU that high with no actors. Try using the console command stat GPU and see what all is at the top of the list. It might give more clues to what could be causing this.

Second, the Draw is the primary thing that is shooting up with the actors. If your scene is primarily just rooms, try using a large Cull Distance Volume that starts culling things out of rooms that the player can’t possibly be in at the time. (For example, if you are in a room that is all the way on one side of the house, you should be able to set the cull volume to remove things that are at least on the other side.)

Here is a video if you want information on how to use: WTF Is? Volume - Cull Distance in Unreal Engine 4 - YouTube

There is no way that just that is going to fix it, but it will be interesting to see if cull distance does anything notable.

EDIT: You know what? If we go single step every post we are going to be here forever. There are a bunch of diagnostic tools for the viewport. Can you have a look at Shader Complexity and also Quad Overdraw? Tell me if you have a lot that is high on those.

Also, do you have a lot of any of the following: Objects with more than 4 materials on them, translucent objects, dynamic shadows, or materials with more than 300 instructions in them that cover a lot of surfaces.

2nd EDIT: Also, go to project settings->general settings and temporarily turn off the smooth frame rate option if you have it on.

Hey thanks for the help.

The images I first posted may appear backwards. The higher values are with actors in the level, the lower values after removing most. I find it confusing that culling is coming into it when the walls should be blocking objects beyond the walls. But lets see what happens with adjusting it.

Here are the GPU stats before making any changes. Same scene, all actors present.

319317-stat-gpu.jpg

Most of the materials are based off Megascans. I know, not the simplest. Objects typically have 3 materials. The only glass in the scene are wall lamps, otherwise everything is opaque. There are windows on the exterior (outside of view), not much else translucent.

I’ll post my results as I get them

I find it confusing that culling is coming into it when the walls should be blocking objects beyond the walls.

It is true that the objects are already being not rendered because they are not seen, but there are various ways that the engine figures out how they aren’t seen in the first place. The distance pass is one of the most performant parts of deciding what is/isn’t on the screen at the time. Otherwise, you have to rely on frustum culling or occlusion culling for it to figure out that the objects aren’t on the screen at the time, and those can be more expensive than distance culling.

Though, really, culling was just a guess that didn’t end up mattering much anyway because according to your stat GPU, the problem is clearly the shadows!

How many lights in your scene are movable or otherwise dynamic? Do you have any large dynamic lighting features enabled?

EDIT: You could also try baking all your static lighting if you haven’t yet. I don’t know if unbaked lighting previews would cause anything, but we are trying everything we can think of here. :slight_smile:

2nd EDIT: I have an idea on how to test if it is 100% just the shadows or if it is other things. Go to settings (from the viewport toolbar) then to engine scalability settings and set shadows to low. This is just the shadows while running the engine (it won’t affect a finished game), but it is useful to test if that is what you need to fix or not.

Shader Complexity and Quad Overdraw only seem focused on the glass objects I mentioned. Otherwise everything is blue or green (low)

So with everything else Epic except shadows on low, there is literally no lag. So shadows seem to be a major problem. Even though the lighting is mostly spots, I have them dynamic to allow the user to switch them off (or I might want to mess with them later like have all the lights go out). Haven’t figured out the gameplay yet. I can try converting some to static, build lighting and see what happens.

Well, at least we figured out the problem!

There are a few things you can do from here.

First, since you seem interested in being able to have lights that can be turned on/off in your game, it should be noted that the lights are not the heavy part. It’s the shadows that are causing the problem. So, in theory, you could keep your lights, but just set a bunch of your objects to not cast shadows.

Another option is to lower shadow quality. Dynamic shadows are greatly affected by poly counts of the meshes that are casting the shadow. So, if you still wanted objects to be “casting shadows” but not be as high a cost, you could be a bit sneaky and get a bunch of low poly objects to set to invisible but leave “cast shadow” on in their details (I believe one of the settings of visibility/hidden in game still allows the object to cast shadow even if it is not visible at the time). Then make sure all your actual objects are not casting shadows, but put them in the same spot as the invisible low poly meshes.

And, the other most obvious, you can do what you have already mentioned and simply remove some of the dynamic lights altogether and replace with static.

Yes it makes sense to focus on a lighting solution. Strange thing is all the lighting in the blueprints show only moveable option, no static, except the one inherited. I made a master blueprint for the various rooms and halls. In it are functions to control doors and drawers and lights (switches). The one base light from the master can be made static, but all other lights added can only be moveable. I find that strange and not sure how to change it. I may have to add static lights outside the blueprints unless you know how to change them.

Also still curious how lighting and shadows becomes more of a problem when actors not visible or casting their shadows are populating the world outside. I am perplexed.

Also still curious how lighting and shadows becomes more of a problem when actors not visible or casting their shadows are populating the world outside. I am perplexed.

I’m also not completely clear on that, but I know that every single object in the game has at least some impact regardless of if you can see it or not because the engine has to figure out if it can see the object or not every single frame. Maybe it does the same for every shadow?

It occurs to me that there is also an option inside each light to control the distance at which it is active. You could try adjusting that to see if that helps fix some of your issue as well.

Anyway, you know what the issue is, and you are working on a solution. Good luck with your game!

Appreciate all your help! Thank you

So I wanted to report my solution. Many thanks to Detach789 for pointing me in the right direction.

The key is Max Draw Distance/Max Distance Fade Range in the light details panel. The sweet spot (pun intended) is 1000 for each. 500 for enclosed spaces. Once I set all my lights, I can fly around in High Preview no trouble.

Hope this helps others