Performance Guidelines for Mobile Devices - Quick Guide

Performance Guidelines for Mobile Devices - A quick reference guide

In-depth documentation here:
https://docs.unrealengine.com/en-US/Platforms/Mobile/Performance/index.html


LDR (Low Dynamic Range)

Low Dynamic Range (LDR) mode is the lowest performance tier supported in UE4 and is recommended for games that do not require lighting or Post Processing features.

To use this mode, you must disable Mobile HDR for your project in the Rendering section of the Project Settings.





Basic Lighting

In this tier, you will leverage Static lighting and fully rough Materials to create levels with interesting lighting while maximizing performance to reach a broader range of mobile devices.

To use this mode, you must disable Mobile HDR for your project in the Rendering section of the Project Settings.


Full HDR (High Dynamic Range) Lighting

In this tier, you take advantage of most of the HDR lighting features available for mobile in UE4, as well as some of the Post Processing features. Using these features requires quite a bit of performance in exchange for high-quality lighting features.

To use this mode, you must enable Mobile HDR for your project in the Rendering section of the Project Settings.




Shader Complexity View Mode

The Shader Complexity view mode in the Mobile Previewer to get a sense of what your Material costs will be for specific devices you are targeting. The colors indicated on screen will tell you how expensive the Material is for the device you're targeting; green means good performance, bright red means very expensive, and white or pink means that the Material is very expensive.

To use it, in the Main Viewport click the View Modes list and select Optimization Viewmodes and choose Shader Complexity, or you can use the keyboard shortcut Alt + 8.




Mobile Content Scale Factor

Mobile Content Scale Factor is a way to scale the resolution of your project to best fit the screen resolution of the mobile device being used to view your project. You can create and store multiple device profiles by creating a new configuration (.ini) file called DefaultDeviceProfiles.ini in your project's config folder.

Inside of this file, you can specify what will happen to the resolution of your project for specific devices by entering the following command followed by one of the values from the iOS and Android sections below:r.MobileContentScaleFactor


Mobile Material Quality Settings

When building content for a UE4 project that will run on both low and high-end mobile devices, you will often run into issues where a feature or your artwork is working on one set of devices but not another. While there are a lot of ways to address issues like this, many of these are both time and resource intensive which can be error prone at times. To address these types of issues UE4 has the Material Quality Level system. This system enables you to build one single Material that can then be used on a wide range of devices, giving you full control over which devices use which features.

In the following sections, we'll cover these systems and how you can use them in your own UE4 projects:
Previewing Material Quality Level

You can view what the different Material Quality Level settings will look like inside the Editor by going to the Main Toolbar and then then selecting Settings > Material Quality Level to choose the level you want to preview.



Setting Material Quality Level

To set the Material Quality Level for your devices, you can do so in the following ways:
From the Console

Bring up the console by hitting the ` (backtick) key and entering r.MaterialQualityLevel followed by one of the following values:



Please note that 1 for high and 2 for medium is correct and not a typo. 0 is Low.


From Device Profiles

Using a configuration (.ini) file, you can set the Material Quality for the devices you plan to target using the following method from within the Editor:

From the Main Toolbar go to Windows > Developer Tools and then click on Device Profiles.



In the Device Profiles find the Android_Low profile and click on the first Wrench icon to open up the profile options.



In the Console Variables section under the Rendering option, click on the Plus icon and in the input window that pops up, input R.MaterialQualityLevel and then press the Enter key to add that command to the list.



Once the new entry has been added, change the value from the default value from 1 to 0 so that when this project is viewed on lower end Android devices it will use the fastest possible Material settings.




Previewing Different Quality Levels

By adjusting the Preview Rendering Level, you can use the Unreal Engine 4 Editor to see how your project will look when running on different hardware. You can adjust this by going to the Main Toolbar and then select Settings > Preview Rendering Level and select the preview level you want to use.




Material Quality Level Switch

The Quality Switch Material Expression enables you to define different levels of complexity within a single Material. For example, if you have a complex math operation, or heavy texture reads that will work on higher-end mobile devices but not on lower-end ones. You can use this node to specify simplified versions to be displayed on lower-end mobile devices that do not have the power to display higher-end graphics.




To use the Quality Switch in your Materials, you will need to first add the Quality Switch Material Expression node to the Material Graph and then plug its output into any of the inputs on the Main Material node. In the following image, the M_Brick_Clay_Old Material (that can be found in the Starter Content) is setup so that when the Quality Level is switched, the complexity of the Material will be reduced.



Mobile Material Options

If you open up any Material and click on the Main Material Node then look in the Details Panel under the Mobile section you will find the following two properties:

Property, Setting, Fully Rough

Forces a Material to be completely rough saving a number of instructions and a single texture sampler.


Use Lightmap Directionality

Uses lightmap directionality and per-pixel normals. If disabled, the lightmaps will be flatter looking visually but cheaper to use.




These two properties can be enabled to help reduce the rendering cost of that Material when viewed on less powerful mobile devices by completely eliminating the rendering path for those features. However, this is, an all-or-nothing option as you either have these options enabled or disabled for this Material on all devices.
Mobile Material Rendering Overrides

You can override the available rendering option a platform will use by adjusting the the Material Quality settings for different target devices located under the Project Settings > Platforms.




Android:

Open GLES 3.1, Vulkan, iOS: Metal

You can override the available rendering option a platform will use by adjusting the Quality Options listed. In order to use the overrides, you must first click on the Enable Quality Overrides option and then select the option you want to override for a given quality level.



Once all of the options you want have been selected, press the Update Preview Shaders button to recompile all the Materials to work with the options specified.



Mobile Rendering Options

Inside of your Project's Settings menu under the Rendering section, you will find a number of properties that control how lighting and optimization will be handled inside of your mobile project. In the following sections we will take a look at these settings and what effect they will have on your project.
Accessing your Project's Settings

To access your project's settings you will first need to go to the Main Toolbar and then select Edit > Project Settings.



Once the Project Settings menu is open, locate the Engine section and then click on the Rendering category. Use the following sections to adjust the settings below:

Mobile, Lighting, Mobile Shader Permutation



Mobile Rendering Options

Under the Mobile category, you can set properties that directly affect the lighting and look of your mobile project. Read on below to explore these settings for your own projects.




Property Name, Description, Mobile HDR

If true, mobile renders in full HDR. Disable this setting for games that do not require lighting features for better performance on slow devices.

Disable Vertex Fogging in mobile shaders

If true, vertex fog will be omitted from all mobile shaders. If your game does not use fog, you should choose this setting to increase shading performance.

Maximum number of CSM cascades to render

The maximum number of cascades with which to render dynamic directional light shadows when using the mobile renderer.


Mobile MSAA

This is the Multi-Sample Anti-Aliasing (MSAA) setting to use on mobile. If MSAA is not available, the current default AA method will be used.

Shader Reduction Settings for Mobile

Under the Lighting and Mobile Shader Permutation Reduction section, you will find a number of different option that can be enabled or disabled to effect shaders generated for Materials, which in-turn will reduce app size, save memory and improve load times.




Property Name, Description, Lighting

The listed options found under the Lighting section of the Project Settings that should be adjusted for mobile performance.

Allow Static Lighting

Whether to allow any static lighting to be generated and used, like lightmaps and shadow maps. Games that only use dynamic lighting or that are unlit should set this to 0 to save some static lighting overhead.

Mobile Shader Permutation Reduction

The listed options found under Mobile Shader Permutation Reduction that should be adjusted for mobile performance.

Support Combined Static and CSM Shadowing

Allows primitives to receive both static and CSM shadows from a stationary light. Disabling will free a mobile texture sampler.

Support Distance Field Shadowing

Generate shaders for primitives to receive distance field shadows from Stationary Directional Lights.

Support Movable Directional Light

Generate shaders for primitives to receive movable directional lights.

Max Movable Point Lights

The number of dynamic point lights to support on mobile devices. Setting this to 0 for games which do not require dynamic point lights will reduce the number of shaders generated.

Use Shared Movable Point Light Shaders

If this setting is enabled, the same shader will be used for any number of dynamic point lights(up to the maximum specified above)hitting a surface. This is slightly slower but reduced the number of shaders generated.

Changing any of these settings will require you to restart the editor before they take effect.

If you disable a shader permutation that your lighting setup requires, your lighting or shadowing will not render correctly and there will be an on-screen message indicating the setting that needs to be re-enabled for it to work properly.
Additional Suggestions

The following suggestions will help to set up your content for optimal performance on mobile platforms. These are listed from most severe to least impactful.


Make sure lighting is built before running on a device.

Most Post Processing features are disabled for mobile platforms as they are too expensive, like like vignette or screen space reflections. Some GPU intensive features like Bloom and Depth of Field are enabled by default so that PC and mobile look the same but many features can cost 60 milliseconds or more with the default settings on some devices. The console command showflag.PostProcessing 0 can be used to turn off these features to get a general idea of their costs.

Make sure to use Precomputed Visibility and that it is set up properly. To do this, place Precomputed Visibility Volumes around areas where the player can walk or jump and then build lighting. You need to make sure to place these in the Persistent level that is used when building lighting and when running the game, so do not build a sublevel by itself. You can verify that Precomputed Visibility is working by entering the console command Stat Initviews on device or in the level previewer and making sure that Statically Occluded Primitives is greater than 0. Use the console command r.ShowPrecomputedVisibilityCells 1 to visualize the cells in the editor.

Use masked and transparent Materials sparingly. Only use them in places where they cover a small part of the screen. iOS devices are very optimal in shading opaque surfaces, as they will only shade each pixel once, but for masked and translucency, every single layer will have to be shaded. The total GPU time of a frame can be doubled or more by having overdraw. Use the Shader Complexity view mode to investigate any hot spots.

Draw calls of the entire scene should be <=700 for any single view. Areas with poor occlusion, like looking over a large landscape, is going to be biggest challenges for this. This can be seen with Stat OpenGLRHI on device or Stat D3D11RHI in the Previewer on PC.

Triangle count of the entire scene should be <=500k for any view. This has been determined to be the maximum poly count that can hit 30fps on both iPad4 and iPad Air. This can be seen with Stat OpenGLRHI on device or Stat D3D11RHI in the Previewer on PC.

Materials should use as few texture lookups and instructions as possible. You have five texture samplers available, but using all of those makes for a fairly expensive Materials. For now, use the PC instruction count to optimize and the Previewer shader complexity to visualize the total cost.

Only use independent texture fetches in Materials. This means UVs in the pixel shader (BaseColor, Roughness, etc.) must not be manipulated in any way, such as scaling. Use the CustomizedUVs feature instead to do the scaling in the Vertex Shader. Some special features like environment mapping require math on the UVs and that is OK for special cases.

It is recommended to use square textures as they have less memory waste. Always use power of two dimensions for these (256x256, 512x512, 1024x1024). Use the console command ListTextures in the Previewer to see where all the texture memory is going.


Mobile Content Scale Factor for Android

For Android devices, inputting the following numbers will produce the following results:

Please note that inputting values other than 0.0 will use this value as the scale factor for a standard 1280x720 or 720x1280 resolution depending on the orientation of the device.

Popular posts from this blog

Quick start guide to using Gaea

Substance Painter 2019.3

Skin Material in UE4