Face Mesh
The Face Mesh Template demonstrates several different ways to use Face Mesh feature. The Face Mesh feature creates a 3D mesh that mimics the user’s face as it changes. The template shows how you can use 2D or 3D content, as well as the material editor to create a unique face effect.
Tutorial
Guide
The Face Mesh Template comes with 4 unique examples. Take a look below for a description of each example and information about their settings.
Extrude Example
The Extrude example allows you to create a 3D mask based on a 2D texture by simulating an extrusion effect by duplicating the Face Mesh multiple times.
The extrusion is done through the FaceMeshExtrude
script which duplicates the Face Mesh in the specified direction.
To customize the script select the Face Mesh Extrude
object in the Objects
panel and adjust its settings in the Inspector
panel.
Extrude Direction
To specify the direction of the extrusion, modify the Extrude Direction
values, where each parameter represents the x, y, z direction of the duplicates relative to the orientation of the Face Mesh.
Count
You can choose how many copies will be created by changing the Count
slider.
Material Editor Example
The Material Editor example demonstrates the use of a material on the Face Mesh.
In the template example, we used Iridescent material from the Material Library. You can find other materials to try by opening the material library by clicking on the Material Library button in the Inspector
panel.
The Iridiscent material used in this template is modified to allow you to add an Opacity mask. By default the template uses an opacity mask that fades out the edges of the mask as well as occlude the inside of the mouth. Take a look at the Face Mesh guide for more information.
Now let’s select a Hologram and click on the Add button.
This will add the material into your project resources.
Lastly, we’ll use our material on our Face Mesh by selecting the Face Mesh object and applying the material in the Inspector
panel.
You can also use the PBR material (Resources panel > + > PBR
) to set up a material with custom textures, or even make your own material using the Material Editor.
Pin To Mesh Example
The Pin To Mesh example demonstrates how you can use the Pin To Mesh component to attach any object on to Face Mesh object which will react to the user’s facial movement.
You can see how the Pin To Mesh works by selecting the Pin To Mesh Left
or Pin To Mesh Right
object in the Objects
panel.
In the Inspector panel you can see the Face Mesh object is set as a Target
on the Pin To Mesh object. You can modify where your object is pinned to the mesh by modifying the Pin UV
parameters.
Shiny Face Example
The Shiny Face example uses the reflection of a material to create an effect on the user’s face.
Using Your Own Reflection
You can import your own environment map to change what your face mesh reflects.
To do this, import an environment map by dragging and dropping a .hdr
file format files into the Resources
panel. This will automatically creates both Diffuse and Specular map that we can use in our Lens.
To change the Environment map being used, select the Shiny Face Envmap [EDIT_ME]
object and replace the parameters with the environment map textures that were generated by the file we just imported.
Take a look at the Lights and Shadow guide on the Lens Studio website to learn more about reflections and environment maps.
Animating Environment Maps
This example also contains a helper script which will rotate the environment map based on the time and loop count to animate the reflection.
To customize the rotation speed select the RotateEnvMap Controller EDIT_ME
object in the Objects
panel and adjust its settings in the Inspector
panel.
Duration
You can change the rotation speed by changing the Duration
value.
Loop Count
You can change the number of times it loops by changing the Loop Count
. If you wish to have an infinite loop, change the loop count to -1
.
You can modify which part of the Face Mesh is visible using an Opacity Mask, as well as whether the eyes and mouth are filled in. Take a look at the Face Mesh guide for more information.
Previewing Your Lens
You’re now ready to preview your Lens! To preview your Lens in Snapchat, follow the Pairing to Snapchat guide.
Related Guides
Please refer to the guides below for additional information: