Poor performance in Magic Leap 2

618
4
09-28-2023 05:46 AM
MBambino_ATS
New Contributor III

I am developing an app for the Magic Leap 2 using the Unity Maps SDK.

When the map show's a scene layer, the framerate drops to very low levels. I've tried this with multiple different scene layers and the all perform poorly, regardless of the detail of the buildings being shown.

This issue was seen in version 1.1.0 before native support of tabletop mode was added. I have since updated to 1.3.0 and switched to using the native tabletop method, but the performance issues still exist.

I am using Unity 2022.2.21 with URP. I've tried with an without various optimization settings (multi-threaded rendering, dynamic batching, etc.)

It's worth noting that if no scene layer is being rendered (just the map) the performance is smooth. Also setting the render scale to 25% generally smooths things out even with a scene layer.

Any help or input would be greatly appreciated!

0 Kudos
4 Replies
MarkusWall1
New Contributor III

Can you post your computer configuration? We are running a lot of scene layers with HTC Vive in VR and they are performing really well. 

Are you streaming the scene layer from portal, online or from slpk files?

An issue, that I've observed with our configureation is, that the overall performance of the VR mode is worse when unity is not running in adminitration mode.

0 Kudos
MBambino_ATS
New Contributor III

The app (once built) runs natively on the Magic Leap device. it should, in theory, be powerful enough to render a scene layer without issue. I have no performance issues whatsoever when testing in the editor. (intel i7, GTX 2060).

The layers are being streamed from tiles.arcgis.com

0 Kudos
MarkusWall1
New Contributor III

So it runs smooth on your computer, right. Maybe the graphics chip from magic leap has to less performance to run the 3d model. Or the models are not optimized for one of this graphics chips. 

Unfortuately I haven't found any performance comparisons of the AMD GFX10.2. But the graphics chip has to render twice the images of your computer in a higher framerate.

Maybe someone from Esri reads that topic and has an answer to that issue.

0 Kudos
MBambino_ATS
New Contributor III

UPDATE: I've figured something out, though it is not a solution.

Something I've learned about the way that terrain and buildings are handled under the hood: The SDK renders far more than you can see. Specifically, if you are using a local scene with extents, it renders everything in and around the extents you provide, and then it clips every pixel that does not fall within those extents inside of the shader. It does appear to use frustum culling to some extent, so if you look away from the map entirely, it will no longer render.

The performance drop comes from the fact that for every pixel of every triangle that the map is trying to render, all shader code is being executed to set up the color of the pixel, but then extra code is performed to set the alpha of the pixel, which then gets clipped if it's below a certain value. This means that every triangle drawn is doing extra work regardless of whether it is visible or not. By removing the node that connects to the alpha on the tile shader, the performance becomes almost perfect at the expense that nothing is clipped anymore, so the extent you define just tells the map where to focus detail on, but also shows everything around it, too. I also noticed that the shader responsible for buildings is not using backface culling, which is causing some slight performance loss.

I don't have a solution to this, but just wanted this in writing in case any of the developers see this.

0 Kudos