Boolean Checks And Sets Affect On Performance

Hello!

I’ve checked around, and opinions seem to vary. Can anyone give me any insight as to how expensive a Boolean check is?

An example is this:

Where my project is checking the player’s location to know whether or not it should render a very large object (usually a scene, background, or imposter mesh).

I’ve noticed HUGE improvements to performance by hiding meshes, however, there are times when hiding meshes solely by distance isn’t enough. If a character is close to a large building, but is indoors, for example, I set this Boolean to check for the character’s location.

What I’ve noticed is that I get framerate dips every 1.2 seconds (which is the frequency that the game checks), but only in the Editor, not the packaged game.

  1. Does checking a Boolean value for dozens of items cause this?
  2. Is it better to reiterate a condition or bypass it if it is already in its similarly set condition? For example:


-Does Unreal reset the visibility or bypass it if the test value remains the same?

Shouldn’t occlusion culling do this by default? Perhaps your static mesh bounds are setup wrong?

You are also doing distance calculations each call of you custom cull.
You could get a boost by moving this to c++ but it still seems odd to have to even use it.

Edit
When indoors try the console command Freeze Rendering and then eject from your player character and see if the meshes outside are culled.

2 Likes

Maybe unrelated, but seems like these variables have not been added to this class?
image

1 Like

It may be because the print statement is disconnected so they aren’t evaluated in the blueprint compile. Notice that there are no compile errors regarding missing variables on an ok compile (green tick).

1 Like

I agree with you about the Occlusion Culling!

However, I noticed further gains in FPS by creating my own cull functions. I actually disabled all of my cull functions to test how the Occlusion Culling is doing, and it’s less performant. But the FREEZE RENDER console command I will use to get more insight!

@pezzott1 , those are just debugs, and have been disconnected. They should affect nothing.

EDIT: Keep in mind that my scene is VERY, VERY large with MANY components.

Ah, now I remember why the occlusion is an issue:

I’m using imposters/los-res models, so I need to govern when they should and should not be visible.

Perhaps a building manager would be a better solution.
When the character enters a building temporarily hide all objects that are not part of the building, upon exit unhide them. No ticks, delays needed. Move it to an event based system (character enters building / exits building)

And don’t gather the objects each time, have a list of static items that are effected in the level per building.

Move as little data around as possible.

I won’t take much more of your time, but isn’t an overlap function still a form of tick function? There’s a lot of buildings, so I’m trying to figure out the best way to go about this.

And again, there are times I need buildings to be visible even while you are indoors. (Like far away buildings), but those far-away buildings need to be replaced by the actual mesh when you get close.

EDIT:

Yeah, so you’re confirming my suspicion that multiple checks will definitely affect performance. I’ve already started moving in the direction of your advice, and will have a “manager” instead of checking on each instance/iteration.

Everything takes up cycles unless you offload it to a separate thread.

Without dismissing @3dRaven solution: I would make sure to exhaust all optimization techniques offered by the engine before getting creative.

@pezzott1 , I mean, you’re right, but I don’t think you’re completely processing what I’m saying. To save you the trouble of (re)reading my posts, yes, I have exhausted the native optimization techniques, but there are instances where they are not enough or appropriate. (Again, mentioned above).

(Graphical) Optimization was never my issue. My issue was more of a question of how the Engine processes Boolean data and how best to handle large amounts of it.

1 Like

You could also split the map into sectors and based on that use a descriptive enum.
An enum has an underlying uint8 so very small and lightweight to evaluate.

This would narrow down the area you are in. You could do the needed calculations based on the delegated sector (this could be driven either by coordinates or trigger volumes)

Funny you say that, because that’s the basis of my “building/occlusion manager”!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.