Introduction to Blocks
Introduction to Blocks
Face Tracking in Blocks

Face Tracking in Blocks

Using a face tracker in a block lets you save and export different face effects in Spark AR Studio, to be used again and shared with other creators.

For example, you could create a makeup effect for one user, with two different blocks in use: one to change the appearance of the lips and one to add eye shadow.

Alternatively, you could add two blocks to a project to track two different faces, making each person look like a different character in a story.

Adding inputs to assign the face tracker correctly

If you add a block containing a face tracker to a scene without creating any block inputs, it will automatically track the first face in the scene and you'll not be able to change this once the block or blocks are added to the main project.

Instead, you can add inputs to assign your block to the correct face in the scene and enable creators to edit this via the Inspector in the main project.

This is especially useful if creating blocks representing different characters in a scene, where creators may want to change the face the block is assigned to.

Example

In the example below a face tracker and face mesh were added to a block. The block has two inputs, listed in the Inspector:

  • Face Number: to set the default face mesh to track.
  • Face Color: to configure a default color for the face mesh.

In the Patch Editor, a patch representing Block Root is connected so that the face tracker and mesh take on these default values:

  • The output of faceTracker0 is connected to a patch representing the Tracked Face property of face mesh0.
  • The Face Number port of a patch representing Block Root is connected to the Index port of the Face Select patch.
  • The Face Color port of Block Root is connected to a patch representing the Diffuse Texture of the face mesh.

The patch graph and block inputs are now set up so that users adding this block to their main project will be able to change the color of the face mesh and edit which face the mesh is assigned to via the Inspector.

In the example below, we added the block to a project with a real-time simulation of two faces in the scene. We instantiated the same block twice: it's listed as block0 and block1 in the Scene panel.

In the inspector we edited block0 by changing:

  • The Face Number input to 0, to track the first face in the scene.
  • The Face Color input to green.

We edited block1 by changing:

  • The Face Number input to 1, to track the second face in the scene.
  • The Face Color input to red.

Was this article helpful?