Unity-Technologies / arfoundation-demos

AR Foundation demo projects
Other
496 stars 130 forks source link

BlurredShadow performance issues #39

Closed Ardoos closed 3 years ago

Ardoos commented 3 years ago

I'm testing out different plane shadow solutions in my AR game. So far I've been using this solution https://github.com/HippoAR/Unity-Technologies-unity-arkit-plugin/blob/master/Assets/UnityARKitPlugin/Examples/Common/Shaders/MobileARShadow.shader. It's highly efficient, but your Blurred Shadows solution fits my game art style way better.

My game is 30 FPS capped, I'm testing it on Galaxy Tab S6 Lite and Galaxy S10. With MobileARShadow both devices has stable 30 FPS. When I use BlurredShadow Galaxy S10 is still doing great, but S6 Lite drops to 12-15 FPS. Can I adjust some settings to avoid this drop? It's pretty weird that shadow casted by 1 object cuts framerate by half, even on device like S6 Lite.

DanMillerDev commented 3 years ago

The blurred shadow do have a much higher performance cost as it's doing more complex calculations for the blur. I know there were some issues with the android platform over iOS but thanks for raising this issue. I will look into it and see if there is some guidance I can offer for improving performance.

DanMillerDev commented 3 years ago

I've updated the documentation with two ways to increase performance https://github.com/Unity-Technologies/arfoundation-demos/commit/c85e687205bc3cfb01bc36769a7d485492b8d346

First make sure shadow cascades are disabled in the URP pipeline assset, next you can edit the HLSL files used for the blurred shadows and contact shadows to cut the number if iterations in both by half. There will be some visual differences but this should increase performance and still have a similar visual style.