Segmentation
Segmentation feature allows users to remove, change and animate backgrounds and body parts without chroma key. Currently the following segmentation types are available:
- Background
- Body
- Face
- Hair
- Neck
- Skin
- Lips
- Brows
- Eyes (pupil, sclera, iris)
How to add Segmentation feature to your Effect
- Find
SegmentationFeature.prefab
in Project window, drag and drop it into your effect'sSurface
object in Hierarchy window.
- Provide
SegmentationFeature
script with the reference of your effect'sCameraPlane
object. Choose segmentation type fromType
dropbox in Inspector window.
- Create and set custom material with
BNB/Segmentation
shader toMaterial
property ofRawImage
component onSegmentationFeature
object. You can find a simple example material in Assets => BanubaFaceAR => FeatureSegmentation => Materials folder.
- Effect is ready!
Segmentation with Unity Face AR SDK example scene
Find and open SegmentationExample.unity scene under Assets => BanubaFaceAR => FeatureSegmentation => Scenes. See full image
Run the scene to see how it works.
Background segmentation example
Add Segmentation example to mobile device build
- Step for Android only: open Edit => Project Settings => Player and select Android tab. Remove Vulkan from the Graphics API (leave only OpenGLES3). It's better to restart Unity editor afterwards.
- Open File => Build Settings and select your platform. Click Add Open Scenes to add SegmentationExample. Leave active only LoaderScene and SegmentationExample. Make sure their indexes are 0 and 1 respectively.
- Click Switch Platform and then Build And Run.