While it's important that effects are engaging and high quality, they should also perform well on a variety of devices.
This article covers a range to ways to improve the performance of your effect. It also outlines technical guidelines for imported objects and textures.
The highest impact changes you can make are to reduce the number of capabilities in your project, reduce the size of 3D objects and optimize your use of textures.
These are the maximum limits for object count, texture resolution and triangle count for 3D objects. You should follow these limits below, as well as the optimization guidelines on this page, to strike a balance between quality and performance.
We recommended adding no more than 50 objects to a scene.
The maximum resolution for a texture is 1024 px x 1024 px. Any textures you add to a project that are larger than this will be automatically resized.
When importing 3D objects, please note that
Capabilities and features, for example face tracking and audio, are added automatically to your project as you build an effect. The more capabilities you add, the higher the impact on performance.
To check which capabilities are in your project:
Before you export your project, make sure you've removed any capabilities that aren't used in the effect.
Segmentation has a high impact on performance. We've found that effects with both segmentation and the face tracker don't perform well. It's best to avoid using these capabilities in the same effect. Segmentation only works on newer devices. iOS devices must be iPhone 6S or later. Android devices must be Samsung Galaxy S6, Sony Xperia Z2 or equivalent, or later.
Find out more about reducing the impact 3D objects have on the performance of your effect. You should also read the article on creating 3D objects for Spark AR Studio to get the best results.
If you create 3D objects with Blender, use Spark AR Toolkit to optimize your objects before exporting them to Spark AR Studio.
3D objects contain triangles. The number of triangles in a 3D object, or 'triangle count', is a useful way to tell how big or small an object is. This count has the most impact on the size and performance of 3D models, so to achieve a performant effect it’s a good idea to keep the triangle count as low as possible.
We recommend keeping the maximum number triangles per object below 50,000. Keep the total triangle count for all objects in an effect below 150,000.
You can check the triangle count in your 3D modeling software.
You’ll also hear some artists refer to the polygon count. Because polygons are made up of triangles, it’s best to focus on the triangle count for the most detailed and accurate view of the size of your mesh.
Generally, it's better for performance to have a small number of objects in your effect with a higher number or triangles and vertices, than many objects with a slightly lower count.
Where possible, you should also:
Avoid using complex blend shapes where possible.
To reduce the impact of 3D objects with animations on your effect, use the least amount of bones possible.
As well as the suggestions on this page, experimenting with different compression settings can have a big impact on the performance of your effect. Find out more about compression in Spark AR Studio.
Make textures as small as you can wherever possible.
When you're deciding on texture size, it's worth thinking about how the texture will actually look on a device. For example, if a texture won't be seen close up by someone using an effect, there's probably no need for it to be high in resolution.
The maximum resolution for a texture is 1024x1024. Any textures you add to a project that are larger than this will be automatically resized.
It's really important to trim textures when you can. For example, use a lip texture to create a lipstick effect instead of a full face texture.
You can also try using the same texture multiple times - for example, tiling, mirroring or rotating it to generate more detail and variety.
Using texture atlases are a great way to reduce the number of textures used in an effect. Use software like TexturePacker to pack multiple small textures into one square texture.
Make sure textures are square and sized to the power of 2 (example: 2x2, 4x4, 16x16, 32x32). Some texture compression options, like PVR, require textures to be in this format.
You can import any ratio of texture into Spark AR Studio, but it doesn't conform to a power of 2 ratio the texture won't be used as efficiently as possible. You also won't have access to certain tiling and LOD features that can help improve performance.
Alpha channels increase the size of the texture. Only turn them on if you know that your effect needs them, for example if a texture has a cut out shape.
If you're using alpha channels for alpha blending, it's worth trying additive or multiplicative blending, instead. Experiment with changing Blend Mode to Add or Multiply. If your effect still looks good, it's a good way to improve performance.
You can also make changes to compression settings to reduce the impact of alpha channels.
If a texture includes pixels that are either fully visible or fully invisible - without any transition between them - use ETC1/ETC2 with 1-bit alpha. It's half the size of ETC2 with full alpha. You can also use ETC1/ETC2 RGB (no alpha) instead of ETC2 RGBA - it's half the size.
Use sprite sheets or atlas textures instead of a sequence for animated textures. This helps with performance because the effect only needs to load one texture, rather than several.
You should also avoid long 2D texture sequences. If possible, render your sequence every other frame and avoid making 24 or 30 FPS sequences.
Using procedural texture animation instead of sequences will also improve performance.
Visual shaders allow you to create complex visual effects, without having a high impact on performance.
These are the objects listed in the Scene tab.
Don't add more than 50 objects to your scene.
This number refers to objects listed in the Scene tab. It includes everything listed - for example null objects, lights and text. It also includes face mesh.
This number doesn't include assets, like textures and materials listed in the Assets panel.
The more complex your 3D models are, the fewer objects you should include. Including a few high quality objects in a scene is better for performance than adding lots of low quality objects.
First try reducing the Lifespan of particles. In particular, try to make sure particles don't extend beyond what can be seen in the camera. You can check this by comparing what's visible in the Viewport, with what you can see in the Simulator in Spark AR Studio.
You can also:
The more light sources in the scene, the higher the impact on performance.
Some light sources have more impact than others on the performance of an effect. Below, we've listed each light source in Spark AR Studio, starting with the lowest impact and ending with the highest:
It's a good idea to remove the ambient light automatically included in a project where possible. For example, if you're creating an effect with 2D objects that don't require realistic lighting.
Grouping patches can improve performance.
You should also avoid duplicating logic - for example, calculating the same value more than once.