Sprites not rendering when SF_Grid is off

Hello,
I recently encountered an issue where sprites would stop rendering in the level editor viewport. I found this closed ticket UE-199942 marked as cannot reproduce that I suspect is the same bug. I believe I’ve found the cause and have implemented a fix for this, which I’d like to report/share. The ticket I’ve linked recommended I make a post here, since the ticket is closed.

The sprites in question are specifically editor primitives. Things like the little icons which represent various kinds of lights in a scene. These sprites, at render time, are stored in a structure called the EditorSimpleElementCollector, which sits on an FViewInfo. The FViewInfo also holds a few other editor primitives in other structures, e.g. the ViewMeshElements, which seems to be the place that primitive editor meshes are stored (such as the Grid that the Grid show flag turns on/off in the level editor viewport- we’ll come back to that).

When it comes time to render these editor primitives, it turns out that the renderer will only bother to add the editor primitives to the post processing step if there is a nonzero number of view meshes, batched elements, or other such things stored in the FViewInfo. Otherwise, it will skip this rendering step. This check occurs in FSceneRenderer::ShouldCompositeEditorPrimitives in SceneRendering.cpp. This check does NOT include whether the EditorSimpleElementCollector has renderable items.

So, if you have the Grid turned on, it counts as a View Mesh, and that adds the Editor Primitives to the post processing queue, and causes sprites to be rendered incidentally. If you have the grid turned off, or (and here’s why it may be tricky to repro) you don’t have any other editor primitives that the renderer will check for, then sprites will be skipped over, whether they exist or not.

The fix I have for this is simple, I just added “View.EditorSimpleElementCollector.HasAnyPrimitives()” to the long if statement in the middle of ShouldCompositeEditorPrimitives as one of the conditions which returns true.

To see this repro easily, edit a level such that it contains absolutely nothing except a single point light. Turning the grid on/off in the level editor show settings will make the sprite for that light also turn on/off. Adding the check I specified above makes the Grid setting and appearance of editor sprites independent.

I hope this is of help. I’m sorry for the length for such a simple thing, but I wanted to be thorough in my reporting.