Learn to create the Bunny Mask effect!
This effect is one of our featured templates. You can find it by opening Spark AR Studio and selecting Samples, or by downloading the sample content. You can adapt any of the assets in this effect to create your own projects.
In this guide, you'll learn about:
You can also find out more about what's in the finished effect.
If you want to build this effect yourself, open the unfinished effect in the sample content folder. So you can get started quickly, we've already:
Create the make up effect by applying a custom texture to a face mesh.
Start by creating a face mesh as a child of the face tracker that's already in the scene. To help you keep track, rename it. We chose faceMeshMakeup.In the Inspector panel, create a new material for faceMeshMakeup. Rename the material bunnyMakeup_mat.
You'll need to make a few changes to bunnyMakeup_mat in the Inspector panel:
The make up looks quite bright at the moment. Under Render Options there are a few changes you can make, so it looks more natural:
Your project should look like this:
Create a second face mesh and rename it faceMeshRetouch.
In the Inspector panel, create a new material for faceMeshRetouch. Change the Shader Type to Retouching.
You can adjust the sliders to make skin look smoother and eyes and teeth look whiter. For this effect we chose 100% for each.
To distort the shape of the face, you'll apply a 3D object called a blend shape. It's listed in the Assets panel as bunnyFaceMorph. This blend shape makes the eyes and cheeks a bit rounder, and the mouth a bit smaller.
Create a face mesh and rename it faceMeshDistortion. In the Inspector panel:
The shape of the face should look different now:
The whiskers and ears are 3D objects. You'll add these objects to the scene as children of the null objects. This is because they have animations included in the file, which already control their position, scale and rotation. To change these properties in the 3D objects, we can adjust the null objects instead.
To add the objects to scene, drag them from the Assets panel into the Scene tab. We added each object to the scene twice:
Adjust the null objects to set the position of the ears. We used the manipulators to work out the best position, but you could also set the position in the Inspector panel. For:
For bunnyEarRotator_right, next to Scale change X to -1. This will flip the ear over to the other side.
We used the Patch Editor to position the whiskers, so they're placed precisely below the nose.
First we need to flip one of the whiskers over to the other side of the face, like we did with the ears. So:
In the finished effect, we've manipulated the properties of the null objects to position the whiskers.
To create patches to represent the position of the null objects, select bunnyWhiskerRotator_left and bunnyWhisterRotator_right. You can hold down command on your keyboard to select them both at the same time.
For both Add patches, change the Type to Point 3D, because we're positioning the whiskers on a 3D object in 3D space.
Connect Nose to the Face port in facetracker0, to capture data on the position of the nose in the scene.
Connect: 1. The Left Nostril Position port in the Nose patch to the input port at the top of an Add patch. 2. The Right Nostril Position port in the Nose patch to the input port at the top of the other Add patch. 3. The output port of each Add patch to the patches representing the 3D position of each object.
Your graph should look like this:
We tweaked the Add patches, so the whiskers are in exactly the right place. Adjust the X, Y and Z values along the bottom of the add patches:
The whiskers should now be placed directly under the nose.
The 3D object we've used to create the whiskers has an animation included in the file. The animation is listed as wiggle in the Assets panel. To make the animation play in the effect, we'll use an animation playback controller:
To connect the playback controller to the objects in the scene:
Select the animation playback controller. You'll be able to adjust its properties in the Inspector panel:
The ears also have animations included in the object files. We could use an animation playback controller to animate the ears too, but in the finished effect we've used the Patch Editor instead. This is so we can add a Delay patch, making the animation for each ear start at a slightly different time so the movement looks more natural.
To create patches representing the Animation property of the objects:
Next, create the animation patches. Right-click in the Patch Editor and select:
Under BunnyEar_animated in the Assets panel, select Swing and drag it into the Patch Editor.
First connect the Animation Player patches:
To add the Delay patch:
Set the Duration value in the Delay patch. We went with 0.43 seconds.
Your graph should look like this:
The ears should now be animated.
We've used a Screen Tap, Counter and Option Picker to count through different color options when the screen is tapped.
From the menu in the Patch Editor, select a:
Next, create patches to represent the texture and material:
Connect the patches, so your graph looks like this:
Add color options for the ears in the Option Picker. We picked blue and pink, but you could go with something else.
In the Counter patch, make sure the Maximum Count matches the number of options in the Option Picker. We set it to 2.
You can test this part of the effect by clicking the gear in the Simulator, and selecting Simulate Touch:
In real life the ears would move in response to the movement of the head, instead of in a uniform way like they are at the moment. For example if the head moved quickly, so would the ears.
To achieve this effect we're going to use exponential smoothing. We've added a Patch Group to the project that you can use to do this. It's listed in the Assets panel as Exponential Smooth Vec3.
We'll use the rotation of the user's head to trigger the exponential smoothing. So when the head rotates, exponential smoothing will cause the ears to move in response.
If you click the right corner of the patch group, the group will expand. You'll see it's made of several patches:
The input is driven by the 3D Rotation of the face tracker.
Unpack allows us to take each of these coordinates and perform separate operations on them. In this case, we've used Exponential Smoothing patches to return a smoothed signal, based on the Damping factor. In this case, we set the Damping factor to 200 milliseconds.
Click Back to Main to return to the graph.
Your graph should look like this:
We've added an instruction token to this effect. We've used:
Congratulations! You've now completed the effect.
Find out what's happening in the finished effect.
bunnyEar_animated is a 3D object. We've instantiated this object twice in the scene, to create the ears. It includes an animation, swing, a material and a texture.
bunnyFaceMorph is a morph object. We've applied it to a face mesh, to distort the shape of the face.
bunnyWhisker_animated is another 3D object. Again, we've instantiated this object twice in the scene to create the whiskers. It includes an animation, wiggle, and a material.
faceWarpMaterial0, combined with the bunnyFaceMorph, creates the face distortion effect.
BunnyMakeup_mat has the texture bunnyMakeup_tex applied to it, to create the make up effect.
faceRetouch_mat is where we've used Spark AR Studio to create the retouching effect.
We've applied bunnyMakeup_tex to a material to create the makeup effect.
bunny_tex is applied to the ears. We've used the Patch Editor to define its color.
Exponential Smooth Vec3 is a patch group that we've used to apply a smoothing effect to the animation of the ears.
Whiskers Animation Playback Controller controls the animation of the whiskers in the scene.
All objects are children of a face tracker - so they respond to the movement of the user's face.
The 3D objects that create the ears and whiskers have been grouped under 4 null objects. In the image below, bunnyEarRotator_left is the null object. We made patches to represent some of the properties of these null objects, and manipulated them using the Patch Editor. Underneath each container, you can see the skeletons, joints and mesh that make up the object:
There are 3 face mesh in the scene - this is where we've applied the make up texture, retouching material and deformation effect.