Occlusion culling one frame lag

There seams to be a one frame lag between the moment when a static mesh becomes unoccluded and when it begins being rendered.

The problem disappears when occlusion culling is disabled in project settings (obviously). It also can be minimized with bounds scaling, but values have to be quite high (above 5.0).

There’s also a similar issue when traversing the level in editor. Sometimes a mesh does not render until you move the camera.

What could be causing this issue?

EDIT: Attached example project for UE 4.8.0 (Culling.zip)

Hey,

can you check the console command r.OneFrameThreadLag ? Its set to 1 by default and controls the synchronization of the game with the render thread. Try with a setting of 0.

Cheers,
Oliver

Hi Marcin,

There is a couple of options to try that you may or may not have explored. I used your test scene as a base for any settings I mention below.

  • Bounds Scale: This is mesh specific and can be changed via the details panel. The default value is 1.0. Increasing the bounds scale to 1.15 increased the bounds enough that These object rendered before the noticeable pop-in. Since the walls are broken up into smaller pieces they have a smaller bounds (which can be visualized by going to viewport > Show > advanced > bounds). Smaller object bounds will occlude the object more quickly to better optimize the scene.
  • r.VisualizeOccludedPrimitives: enabling this console command will draw a green box around any occluded primitive. This works while editing, but not during PIE/simulate. This can be useful when adjusting the bounds scale of objects to see if they are occluded or not.
  • Project Settings > Rendering: Disabling Occlusion Culling completely. Not really an option for most, but an option none-the-less.
  • r.HZBOcclusion: This setting used to be enabled by default (which if you look at the tip in the output log will indicate 1 use to be the default), but needs to be enabled now to use since it still needs a little bit of work. HZB Occlusion’s results are more approximate, but it is meant to scale better.
    - 0 (default): disabled
    - 1: Use HZB occlusion system (Less GPU and CPU cost, more conservative results)
    - 2: Froce HZB occlusion system (overrides rendering platform preferences)

Enabling HZB Occlusion will likely provide the better result for you without the need for tweaking bounds scales for any meshes that are causing issues. In your test scene, simply enabling HZB occlusion solves the issue. There is the occasional pop-in from the corners if moving the camera really fast, but it’s not as noticeable as before. On the other hand, if it’s only a few meshes that are causing issue then I would suggest adjusting just those meshes bound scales slightly until they do not pop-in like so.

I hope this helps and if you have any questions feel free to let me know.

Tim

Hi,

We think this post contains useful information which we would like to share with our public UE4 community. With your approval, we would like to make a copy of this post on the public AnswerHub which includes the discussion but strips out your username and company name. Please let us know if you are okay with this.

Thanks!

Hi Oliver,

I tried to set it in runtime and with ConsoleVariables.ini, but there’s no change.

Thanks,
Marcin

P.S. Sorry for the delay, but the comment got stuck two days ago somewhere between my browser and the server :wink:

Hi Tim,

Thanks for detailed answer. Would the short answer be, that this behaviour is expected and the assets are not prepared correctly?

As for the bounds scale. If bounds are spheres, as visualized in static mesh editor, they should work well for thin long vertical pieces and horizontal movement, as in attached project. What am I missing?

Thanks, Marcin

Thanks for clearing this out.

Hi Marcin,

All assets are going to be given a bounds scale of 1.0 by default and the bounding box is determined by the mesh itself in the editor. There isn’t really any setup that you have to do aside from getting it into the engine.

The sphere has to bound the geometry just like the box does. The renderer will use whichever one is more appropriate for the operation it is doing. With HZB occlusion it’s looking at more than just the bounds box when considering culling the object. (As a reference the information on how HZB calculates bounds can be found in HZBOcclusion.usf in the source).

Using long then meshes with the default occlusion is going to work more with the bounds box than using the approximation that HZB occlusion can provide. Increasing the bounds manually is the other option for any meshes that are popping in.

Sure, no problem.