Skip to main content

Texture Optimization

Lenses need to be under 8 MB when submitted to Snapchat. Additionally, when loaded on device, they need to consume less than 120 MB of RAM. Often, for creators, the biggest culprit for heavy Lenses is unoptimized 2D assets. This guide will elaborate in detail a few approaches to optimize your 2D assets in your Lens. For more information, please refer to the Performance and Optimization guide.

When building for SPECS, a Lens can be up to 25 MB, and Lens Studio recommends keeping it under 6 MB. Project Settings > General shows how much of that your Lens uses. Unoptimized 2D assets are often what makes a Lens heavy. This page covers ways to make the 2D assets in your Lens smaller; for the compression settings Lens Studio applies, see Compression, and for the rest of a SPECS Lens's performance, see Optimizing Lens Performance.

Find the largest assets in the Asset Browser

The Asset Browser shows how much each asset adds to your Lens's size, so you can start with the largest ones.

  1. In the Asset Browser, click the view button beside the filter button, then select Detail View.
  2. Read Export Size: the size each asset adds to the Lens when you publish it. Click the Name header's sort button to change the order.
The Asset Browser in Detail View: assets grouped into General and Textures, each with its Export Size

To go back to the folder tree, click the view button and select Tree View.

Modifying Images in the Assets Folder

The fastest way to do an optimization pass is to first open your project's Assets folder, where you have direct access to all of the assets in your project. You can find the Assets folder wherever you saved your project (that is, the location of the .esproj file), and then make changes to the textures directly inside the folder.

A Lens Studio project folder in Finder, with the Assets folder outlined

Compression

Try to run all your 2D textures through some form of compression. In most cases, you can reduce an image size significantly using compression without noticeable visual degradation. Photoshop offers a number of compression settings when exporting images.

Lens Studio comes with a built-in compression tool. Take a look at the available options to optimize your Lens. Additionally, you may also consider using other optimization program or software: tinypng.com is straightforward to use and offers big savings for a quick compression pass on images.

Be careful with compressing normal maps and environment maps. In some cases auto compression tools might result in bad normals.

Smaller Textures

Check every texture in your project and make sure that the resolution of the texture is necessary. Reducing the resolution of your texture will have big savings for both the size of the Lens and the Lens’ RAM consumption. Often, 3D textures are made at 2048 × 2048. In many cases, you can reduce these textures to 1024 × 1024 or even 512 × 512 depending on the complexity of the texture and how big you expect the model to be on screen.

When building for SPECS, keep textures at 512 × 512 or smaller where you can: smaller textures also cost less power to render. See Optimizing Lens Performance.

Be on the lookout for single color textures that could be reduce to a single pixel.

A 3D model's textures do not all need to be the same size. For example, if there isn’t much detail in your normal map, try making it smaller than your base color texture.

JPG and PNG

Lens Studio supports two image formats: JPG and PNG. JPG images are often much smaller than PNG, but they don’t support transparency. If your 2D images do not need transparency, try using JPG. Use PNG if you actually need the alpha channel for transparent pixels.

2D Animation

2D animation is often responsible for heavy Lenses. Once you’ve created a 2D animation in Lens Studio, it will save a sprite sheet to your project’s Assets folder. Like any other texture, you can optimize this sprite sheet directly in the Assets folder. Try to reduce the resolution and run compression on this output sprite sheet to reduce the size of your Lens.

A 2D animation's sprite sheet PNG selected in the project's Assets folder in Finder

Take a look at the Compression page to learn more about other ways animation are compressed.

For more details on importing your 2D Animation and the various settings available, follow the 2D Animation guide.