How to reduce the lag in VR games in unity

2020-03-07 10:22发布

问题:

I have been building a game for VR using Unity3d. It has only low poly models and the file size is less then 40 mb still the game lags when played on mobile.. Please suggest how to improve the performance..

Thank you in advance..

回答1:

In order to improve performance in VR for mobile you have to optimize everything as best as you can, you should keep some of these variables in mind:

Graphics Side - Number of polygons in the scene - How many source of lighting do you have

Programming Side - How much work is taking your code, is doing it efficiently?

The programming part can include problems within the physics system, also some logic problems that can probably decrease the overall performance because of higher computation.

My advice is to learn about the Profiler that unity offers, actually you can observe how much work is taking your code and where exactly it is your bottle-neck. This video also can be useful.

Of course a solution could be implement your code following design standards, like design patterns and software architecture (depending on the size of the project).

I hope it can be useful for you!



回答2:

What I found from developing and launching a vr game is some of the issues below

  • Number of polygons is usually your first to check even though your models are low poly. For example, I looked at Synty models in the unity store and some of them were over 1k for a bag and 7k for a character model. This seriously reduce the amount of objects you can if you want to target a max of 50000 per eyes.

With some models, you can use blender and the decimate tool to reduce the polygon count pretty easily. From there I would use LOD's to reduce their count further based on distance.

  • Use occlusion culling (pro version only)
  • Set your camera distance to maybe a 100 instead of the default
  • Use mobile shaders and careful using some of the standard shaders as they are expensive. Also transparent shaders will becomes expensive cause overdraw.
  • Batch your textures and make them static if possible
  • Don't use dynamic shadows on lighting but instead bake your lights
  • Try to avoid using physics as this becomes expensive and instead raycast to trigger events or shooting weapons.
  • Run profiler often and check for any bottlenecks (pro version only)
  • Reduce the count of Particles effects and their values
  • Character bones can also cause issue so remove as many as possible
  • There is also your code to look at as mentioned by Manujamming
  • Set quality setting to low in the inspector to gain best performance.

Could you provide a screenshot of your game scene?

I hope this makes sense. Best of luck!