This is the 25th day of my participation in the August Challenge
Spark AR is Facebook’s free AR creation platform that enables users to create interactive AR experiences for Facebook and Instagram. More than 400,000 creators in 190 countries have used Spark AR to create their own AR creations
Since the software requires no coding knowledge to use, anyone can now lead the world by creating the next crazy viral Instagram AR effects with little experience in the AR world.
Specialized AR filter designers can cost anywhere from $1,000 to $30,000.
Optimization of the texture
In addition to the previous suggestions in this series, experimenting with different texture compression Settings can have a big impact on the performance of the effect.
Reduced texture resolution
Make the texture as small as possible.
When you decide on the texture size, it is necessary to consider how the texture will actually look on the device. For example, if the person using the effect can’t see a texture up close, there may be no need to use high resolution.
The texture has a maximum resolution of 1024×1024. Any texture you add to a project that is larger than this size will be automatically resized.
Reduce the use of textures
It is very important to trim the texture if you can. For example, use lip textures to create lipstick effects instead of the whole 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 atlas is a great way to reduce the number of textures. Use software like TexturePacker to package multiple small textures into a square texture.
Texture compression while preserving image quality, as shown below
- Left: Original, 32 bits/ Pixel
- Medium: Dithering, 16 bits/pixel
- Right: Compression, 4 bits/pixel
Choose an efficient texture size
Make sure the texture is square and has a power of two (e.g., 2×2, 4×4, 16×16, 32×32). Some texture compression options, such as PVR, require textures to be in this format.
You can import textures of any scale in Spark AR Studio, but textures cannot be used as efficiently as possible if they do not conform to a scale of powers of two. You also don’t have access to certain tiling and LOD features that help improve performance.
Reduce texture effects through alpha channels
Alpha channel increases texture size. Turn them on only if you know your effect needs them, for example, if a texture has a cut shape.
If you are using the alpha channel for alpha blending, it is worth trying Add or Multiply blending, which is to try changing the Blend Mode to Add or Multiply. If your results still look good, this is a great way to improve performance.
You can also change the compression Settings to reduce the impact of the alpha channel.
If a texture contains fully visible or completely invisible pixels — there is no transition between them — use ETC1/ETC2 with 1-bit alpha. It is half the size of ETC2 with full alpha. You can also use ETC1/ETC2 RGB(no alpha) instead of ETC2 RGBA – to also save half the size.
Texture usage on iOS devices
The following formatting options are available for iOS devices:
- PNG – When this option is selected, the quality is set to high, lossless recompression is used to ensure small file sizes. When loaded into memory, these textures will take 24 or 32 bits per pixel, depending on the presence or absence of alpha channels.
- JPEG – Optimize JPEG files using MozJPEG. When loaded into memory, these textures will take 24 bits per pixel with no alpha channel.
- PVRTC RGB(2 bits – 2 bits per pixel, no alpha channel.
- PVRTC RGBA(2 bits – 2 bits per pixel, with alpha channel.
- PVRTC RGB(4 bits)- 4 bits per pixel, no alpha channel.
- PVRTC RGBA(4 bits)- 4 bits per pixel with alpha channel.
PVR formats on iOS have the best rendering performance, although they tend to have slightly larger file sizes than PNG.
Texture usage on Android devices
The following formatting options are available for Android devices:
- PNG – When this option is selected, the quality is set to high, lossless recompression applies to ensure that files are smaller.
- When loaded into memory, these textures will take 24 or 32 bits per pixel, depending on whether there is an alpha channel.
- JPEG – Optimize JPEG files using MozJPEG.
- When loaded into memory, these textures will take 24 bits per pixel with no alpha channel.
- ETC2 RGB(4 bits)- 4 bits per pixel, no alpha channel.
- ETC2 RGBA(8-bit)- 8-bit per pixel, alpha channel.
- ETC2 RGB A1(4 bits)- 4 bits per pixel, 1 bit alpha channel.
Pixels can be completely transparent or completely opaque. ETC formats achieve the best rendering performance on Android (although they tend to be slightly larger than PNG).
For older Android devices, you can select the following formatting options:
- PNG – Uses lossless compression through Zopfli to ensure small file sizes. When loaded into memory, these textures will take 24 or 32 bits per pixel, depending on whether there is an alpha channel.
- JPEG – Optimize JPEG files using MozJPEG. When loaded into memory, these textures will take 24 bits per pixel with no alpha channel.
Use textures that drive the painting
Use Sprite Sheets or texture atlases instead of animated texture sequences. This helps with performance, because the effect only needs to load one texture instead of multiple textures.
You should also avoid long 2D texture sequences. If possible, render your sequence every other frame, avoiding 24 – or 30-frame sequences.
Using procedural texture animations instead of sequences will also improve performance.
Use visual shader to optimize performance
Visual shader allows you to create complex visual effects without having a high impact on performance.