Segmentation
The Segmentation Template lets you easily segment a portion of the camera and replace it with an image, tiled image or post effect coloring. Multiple segmentation types are supported including portrait background, hair, sky and more.
Tutorial
Guide
Select Segmentation Controller Object
To tune the Segmentation Template, select the SegmentationController [EDIT_ME]
object in the Objects
panel and then tune its settings in the Inspector
panel.
Set Segmentation Texture
To modify what part of the image is segmented, modify the segmentation texture resource found in the Resources
panel. To do this, select the Segmentation Texture [EDIT_ME]
object, and in the Inspector
panel, modify its settings.
Modify the Type
dropdown to select the part of the image that will be segmented. You can segment:
- Portrait Background
- Portrait Hair
- Portrait Shoulder
- Portrait Head
- Portrait Head
- Sky
All of the segmentation textures can be inverted by enabling the Invert
checkbox.
You can change how the borders of the segmentation looks by modifying the Feathering
and Refine Edge
option.
Background Color
To enable a solid background color, make sure the Use Background Color
checkbox is checked.
Once enabled, you’re able to tune the solid background color and alpha. This background color will be masked by your selected Segmentation Texture.
Image
To enable a segmentation masked image, make sure the Use Image
checkbox is checked.
Set Texture
After selecting you image type, you’ll want to assign the image texture. To add a texture to Lens Studio, drag and drop a PNG or JPG to the Resources
panel. Alternatively, select + -> Import Files
from the Resources
panel. Then, click the Image Texture
field and assign it to your newly imported texture.
Set Alpha
You have control for how transparent your image will be via the Image Alpha
slider.
Set Blend Mode
You can set your image blend mode using the Image Blend Mode
drop down. Available blend modes are Normal
, Screen
& Multiply
.
Tiled
When the Tiled
checkbox is selected, your image is tiled. This tiled background will be masked by your selected segmentation texture.
The following options in the Inspector
panel allow you to configure the tiling.
- Tile Density - How dense the tiled pattern is. Smaller number = smaller tiles. Bigger number = bigger tiles
- Scrolling - If enabled, the tile pattern will play a scrolling animation
- Scroll Speed X - How fast the tile pattern scrolls in the horizontal direction
- Scroll Speed Y - How fast the tile pattern scrolls in the vertical direction
Non-Tiled
When the Tiled
checkbox is not checked, your image texture will be used as a single background image. This image will be masked by your selected segmentation texture.
When using a non-tiled image, you can configure how the image fills the screen by selecting from the Fill Mode
dropdown.
Post Effect
To enable post effect, make sure the Use Post Effect
checkbox is checked.
When enabled, a post effect will be applied to the camera feed, masked by your selected segmentation texture.
You can change your post effect texture by selecting the field next to Post Effect Texture
in the Inspector
panel. Then select a post effect resource. To add a new Post Effect type, select + -> Post Effect Textures
in the Resources
panel or create your own by following the Post Effect guide.
You can also tune the transparency of the applied post effect.
Adding Additional Objects
Not Segmented
To add an additional object that lives on top of the segmentation mask (not segmented). Simply use +
from the Objects
panel as you normally would. As long as the objects are set to either the Default
or Orthographic Camera
layers, the object will not be segmented by the mask.
Segmented
To add an additional object that is segmented, you need to assign your object to the appropriate camera render layer. For perspective camera objects, set your object’s render layer to Masked
. For orthographic camera objects, set your object’s render layer to Orthographic Masked
.
Previewing Your Lens
You’re now ready to preview your Lens experience. To preview your Lens in Snapchat, follow the Pairing to Snapchat guide.
Related Guides
Please refer to the guides below for additional information: