Making a Batched Sprite Renderer - Selection Issues

Hello there!

I am currently prototyping ways to make a batched sprite renderer. My current approach is to have a centralised BatchedRenderActor (with appropriate components) that takes commands from other Actors in the scene that need dynamic geometry batched and rendered. This is all working well except for Actor selection logic.

Currently if you click on any of the rendered geometry in the editor, it will select the main BatchedRenderActor (as expected it is drawing the geometry). But I would like a way to auto select the actor that submitted the render call to the BatchedRenderActor. I’ve been digging into the Selection logic of Unreal and it seems to use a special render pass that can be used to identify HitProxies for the pixels rendered. From this it seems a high level way to solve this would be to either:

  1. Render the individual Actors geometry only into the HitProxy render pass and make the BatchedRenderActor render as normal but non selectable.
    or
  2. During the BatchedRenderActor render pass into the HitProxy map, actually somehow embed info for the individual Actors so when clicked it highlights the correct actor.

I’m not really sure what is the best way to approach this as 1) will potentially have editor performance issues as everything needs a render proxy just for doing selection logic that is then rendered by something else and 2) has issues with actors draw commands will be batched together before the BatchedRenderActor makes its real renderer commands, so this is going to cause issues defining HitProxies.

Any ideas or pointers on how to proceed would be greatly appreciated (even other ways to do the rendering entirely if it means I can still sort and batch the sprites, while still making them selectable)

Thanks!

I’ve been experimenting with both approaches in the previous post and I’ve hit the expected issues with both.

With method 1) when giving the individual sprites their own proxy to render into hit map, I cannot find a way to not render this also into main scene. This way also feels overly complicated as I have to maintain these extra proxies just for hit detection.

Under method 2) I have managed to get the BatchedRenderer mesh draw calls to define a hit proxy of the original actor defining the sprite, and when selected it does indeed select the correct sprite actor rather than the BatchedRenderer. BUT it seems you can only add one hit proxy to each mesh draw command. This is an issue because the BatchedRenderer will group together the geometry of many sprites into one mesh, and therefore different parts of the mesh need different hit proxies.

One solution is to get the BatchedRenderer to individually render the sprites when in the editor and batch them properly when in game, I will need to experiment with this, but I do not like the idea of the performance differences.

Another idea (similar) is to get the BatchedRenderer to render the sprites as normal, but make them non selectable, and then in editor only render the individual sprites (still from the BatchedRenderer proxy) into the hit map only; but I do not know how to render something only into the hit map :confused:

Any ideas?