Search Unity

Mobile performance optimization with Adaptive Performance 4.0

June 29, 2022 in Technology | 11 min. read
Image of performance chart/bar on top of a dark red background
Image of performance chart/bar on top of a dark red background

Download Unity 2022.1 Tech Stream and discover Adaptive Performance 4.0. Push Android performance even further on Samsung devices with four more scalers that cover physics, decals, customization, and layer culling – plus support for visual scripting to optimize app performance.

Unity 2022.1 provides early access to innovative new features that will inform the next Long Term Support (LTS) release. In this verified package, Adaptive Performance 4.0 comes with some great new additions to expand the scaling of your app and enhance its overall performance.

At GDC 2022, we shared the latest updates to Adaptive Performance 4.0 during our talk with Samsung, Unfolding your gaming potential with Galaxy GameDev. Read on for the rundown.

Visual scripting

With our visual scripting integration, just about anyone can leverage Adaptive Performance to scale their app and extend battery life. Upon installing Adaptive Performance 4.0, Unity’s visual scripting system will provide units so you can access Adaptive Performance metrics without implementing anything in C#.

A screenshot of Unity's visual scripting menu
Units accessible with Adaptive Performance 4.0 in Unity’s visual scripting system

In other words, once you install the visual scripting package, Unity automatically activates the Adaptive Performance units. You can then add Adaptive Performance to a project with existing visual scripting graphs, but you must recompile the units. For a detailed demonstration and best practices, check out the Adaptive Performance sample documentation.

As Unity regenerates Adaptive Performance units, you can add new units to your graph by right-clicking the background of any script graph. Go to the Adaptive Performance submenu to locate the units.

Particles in Boat Attack

Here’s an example of how to use Adaptive Performance in visual scripting. The image below represents a slice of Boat Attack, where all particles are disabled on “throttling imminent” and enabled if there are no warnings present. We scale effects such as water waves splashing, boat engine smoke, and paraglider trail formation, as they are heavy on the CPU and GPU. This improves performance with minimal changes to the game itself.

Visual Scripting flowchart

Whenever there is a thermal warning change, we get the Particle System to iterate over it, then stop the Particle System or restart it again. Of course this can be adjusted to the needs of the game. For instance, instead of disabling the effects completely, you can scale the emitter numbers or the quality of the source images.

All Adaptive Performance APIs are reimagined in visual scripting. A full list of APIs and their related information can be found in the visual scripting integration documentation.

Scalers

In addition to the many scalers already available, we added four new scalers to Adaptive Performance 4.0:

  • Layer culling scaler
  • Decals scaler
  • Custom scaler
  • Physics scaler

The benefits of the indexer system, and all the scalers built on top of it, include: 

  • Frame rate stabilization
  • Minimal throttling
  • Rescue from throttling
  • Automatic content scaling during runtime
  • Scaling without recompiling source on millions of devices
  • Simple integration
  • High quality
  • Low maintenance

The custom Adaptive Performance Unity Profiler module shows you how scalers change so you can see if they’re doing their job well or if you need to tweak them. The example below comprises Boat Attack running on a Samsung Fold3 in unfolded mode, which uses a rather high resolution.

Boat attack's main menu's scalers

Boat Attack starts off with plenty of scalers engaged by the menu scene, which was stabilized before the capture was done. In this example, the temperature rises quickly and the device goes into throttling.

Adaptive Performance tries to stabilize the situation and reduce effects on the GPU, as this is clearly the bottleneck. The shadow scalers thereby reduce quality rapidly – but because that’s not enough, both the view distance and resolution decrease as well. The frame rate then stabilizes and the temperature drops. The game is rescued from throttling and its frame rate raises to 60 fps.

Layer culling scaler

With the layer culling scaler, you can dynamically adjust layer cull distances at runtime.

This feature uses the indexer system to make certain decisions, like when and how much to increase or decrease layer cull distances for optimal performance and thermal stability.

The sample we ship with Adaptive Performance loops in medium CPU load until it reaches critical frame rates and then decreases the cull distance of layers. The result of this is that the cull distance for layers changes depending on the CPU and GPU load.

You can set a different value for the culling distance of each layer so that they scale proportionally. This helps you determine which objects to cull earlier to save performance. For details on how to do this, see the following code sample.

Adaptive decals

Adaptive decals target visual effects. In Amazing Adventures of Dr. Arm, there is a boss fight scenario that uses many particles and decal projectors. When the mobile device gets hot and throttling is imminent (or already occurring), the number of particles emitted scales down. In this case, less visually important emitters, things like the leaves blowing in the wind, tiny sparks, and other such elements, turn off completely. The scaler also reduces decal distances.

No warnings

A character wielding a sword faces a cloaked wizard in a forest, who makes red thunderbolts fall from the sky
Image courtesy of Arm

Throttling

A character wielding a sword faces a cloaked wizard in a forest, who makes red thunderbolts fall from the sky
Image courtesy of Arm

Even more, collisions are disabled on some particles. Once the thermal load decreases, we can scale these effects back up.

Custom scaler

The custom scaler implements a fog scaler, and even helps you to create your own scalers when we don’t offer them directly. The custom scaler increases fog and reduces the view distance when the thermal load increases. This action decreases the load on the system so that it can recover.

Post-processing can quickly become one of the most expensive parts of the frame to render. Though not crucial to gameplay, they can add more ambiance and enhance the art that the development team works so hard on.

Adaptive Performance provides the benefit of including the game’s post-processing effects in full range, but also scales back effects that are not needed in moments of peak demand from the device. When throttling is underway, we turn off specific effects in Amazing Adventures of Dr. Arm that were included mainly to enhance the mood of the scene, without substantially impacting gameplay. Fog, Bloom, Depth of Field, Screen Space Ambient Occlusion (SSAO), and Motion Blur are some excellent examples of visual effects that can add a lot, but are not necessary for gameplay. These tweaks enable significant performance improvements in the game.

No warnings

Scene with a forest and field background with an figure aiming at a target through fog
Image courtesy of Arm

Throttling

Scene with a forest and field background with an figure aiming at a target
Image courtesy of Arm

Adaptive Physics

Adaptive Physics changes the fixed delta time at which the physics engine updates. If you use it for other systems, those will be scaled as well. But if you use the fixed delta times in other systems, you might want to create your own physics scaler to employ more detailed settings instead of the fixed delta time.  

See the above comparison of an original Time.fixedDeltaTime value and a scaled-down version. The average frame time of the original is 28 ms and the average frame time of the scaled-down version is 21 ms.

Our Adaptive Performance team is constantly working to extend the package and its platform reach, and we’re excited about the new providers coming in the future. As always, we welcome your feedback on our Adaptive Performance forum. Please don’t hesitate to reach out!

June 29, 2022 in Technology | 11 min. read
Related Posts