Arvtesh / UnityFx.Outline

Screen-space outlines for Unity3d.
MIT License
1.28k stars 90 forks source link

Outline drastically decrease performance with ARFoundation #27

Closed parazite13 closed 3 years ago

parazite13 commented 3 years ago

First of all thank you for sharing this amazing package ! It's the best one I've ever used for rendering outline !

However when I tried to include this package on my last project (AR application on Android), I've noticed a huge drop with my framerate when an outline is visible.

From the screenshots you can clearly see when an outline is visible : image and when it's not : image

For the AR stuff I'm using the MRTK (https://github.com/microsoft/MixedRealityToolkit-Unity) and thus ARFoundation. It seems that this scripting overhead comes from the "NativeApi.UnityARCore_session_update" but as there is a huge difference when an outline is visible, I'm wondering if there is something we can to to prevent this.

Arvtesh commented 3 years ago

Hello, @parazite13, thank you for your interest in my library.

First or all, which outline package and render pipeline do you use? What is the outline settings (width etc), how many outlines are rendered?

There are several main things, that might help you with the outline performance:

Hope this helps.

parazite13 commented 3 years ago

I use the OutlineBehaviour component under the built-in RP.

I have only one OutlineBehaviour in my scene with following settings : image The associated MeshRenderer is a very simple mesh that has only 1600 triangles

The weird part is that the profiler says that it's not a rendering issue but it's due to a scripting overhead that comes from ARFoundation. When I switch my build target to UWP Player (for targeting the HoloLens 2) there is no such overhead anymore.

Arvtesh commented 3 years ago

Outline width of 6 pixels might be too much for mobiles. Try to set 2. If this won't give any significant performance boost, it's probably not outline itself causing the problems. Btw mesh complexity should not be an issue for outline.

parazite13 commented 3 years ago

Ok I tried by reducing the width at 2 and even if its almost not visible I loose between 10-15FPS. Occasionally I'll deep dive into Arfoundation to see where it can come from. Thanks for your time!

Arvtesh commented 3 years ago

@parazite13 one more thong to check is how many cameras render your outlines (there is a read-only list under Cameras in OutlineBehaviour inspector). If there's more than one camera, it is most likely the problem.