CLEAR

Technical Guidelines and Optimization in Spark AR Studio

While it's important that effects are engaging and high quality, they should also perform well on a variety of devices.

This guide 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.

Learn about:

Technical Guidelines

These are the maximum limits for object count, texture resolution and polygon count for 3D models. We recommend following the optimization guidelines on this page, as well as these guidelines, 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 1024x1024. Any textures you add to a project that are larger than this will be automatically resized.

When importing 3D models, we recommend keeping:

  • The maximum number of vertices per object below 20,000.
  • The total triangle count for all objects in an effect below 50,000.

Reducing the Impact of Capabilties and Features

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:

  1. Select Project in the menu bar.
  2. Select Edit Properties....
  3. Select Capabilities.

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, Song Xperia Z2 or equivalent, or later.

Optimizing 3D Objects

Find out more about reducing the impact 3D objects have on the performance of your effect.

Keep the vertex and triangle count for 3D objects as low as possible.

Vertex count has the most impact on the size and performance of 3D models. We recommend keeping the maximum number of vertices per object below 20,000.

Triangle count also impacts the size and performance of 3D objects. You should keep the total triangle count for all objects in an effect below 50,000. Check these values in your 3D modeling software.

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:

  1. Mirror geometry.
  2. Keep polygons in triangles and quads.

Keep in mind that if you've combined 3D objects with other Spark AR Studio capabilities, your effect might still have a slow frame rate, even after you've reduced the polygon count.

Avoid using complex blendshapes where possible.

To reduce the size of 3D animations, use the least amount of bones possible.

Optimizing Textures

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.

Learn more about visual shaders.

Reducing and Optimizing Scene Objects

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:

  1. Set a lower Birthrate.
  2. Use 2 particle systems, placed in the same position, instead of one particle system with a high Birthrate.

Reducing the Impact of Lights

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:

  1. Ambient Light.
  2. Directional Light.
  3. Point Light.
  4. Spot Light.
  5. Environment Light.

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.

Patches and Scripting

Grouping patches can improve performance.

You should also avoid duplicating logic - for example, calculating the same value more than once.

Where possible:

  1. Avoid using subscription.
  2. Cast variables as const.
  3. Avoid scripts with lots of callback and functions for every frame.