There may be differences between your version of Spark AR Studio and this tutorial because the product is currently in beta and we update it regularly.
Learn to create the Holiday Photo effect!
Download the sample content to follow this tutorial. You can adapt any of the assets in this effect in your own projects.
You'll learn about:
To get started open the unfinished effect in the sample content folder. We've already imported the assets you need, to help you get started quickly. We've also removed the directional and ambient lighting from the scene. This is a good idea when you're creating effects with 2D objects, as they don't need lighting to add depth to objects.
We're going to add all the objects at the same time and then assign them to layers so you can clearly see what you're building.
Your project should look like this:
It's worth renaming the objects to help you keep track. Rename:
You'll need 3 layers in this effect, to control the order objects render in.
There will already be 1 layer in the project, named layer0. In the Layers panel, create 2 more.
To keep track of layers, it's a good idea to rename them. We've called:
Back in the Scene panel, assign:
First edit the canvas. Because the rectangles are children of the canvas, they will take on any changes made to it.
In the Inspector, change the Mode from Screen Space to World Space.
Because the canvas is in World Space it will no longer scale with the screen of the device. This allows you to change its Transformations. In the Inspector, change:
We chose these values by adjusting them until we found the best effect. Using the manipulators is a good way to experiment with transforming objects.
Next edit the rectangles:
The rectangles are too small for our effect. To adjust this:
You'll now see a large rectangle in the scene:
At the moment, one rectangle is completely covering the other. To adjust this change the Position of:
Change the Scale of:
Create a material for each rectangle, by clicking the + next to Material in the Inspector.
The Shader Type should be Flat for both materials, because we don't need them to omit or respond to light. It's more performant than a standard shader, so it helps keep the size of the effect down.
Now select overlay_mat. In the Inspector:
The frame is taking shape now:
Overlay_mat changes color when the screen is tapped. You'll use the Patch Editor to do this. Start by creating clicking the arrow next to Texture in the Inspector to make a patch representing the Diffuse Texture property of the material.
We'll add the rest of the patches later.
The text in this effect is a dynamic text object. Dynamic text takes data from a user's device, like their location or the time, and represents it as text.
To add the dynamic text:
There are lots of others types of dynamic text to choose from when creating your own effects.
You'll see the text is in the middle of the frame. To fix this, change the Size values. Click in each of the boxes and select Fill Width and Fill Height to make the text the same width as the canvas:
Next to Pinning, pin the text to the top, bottom and both sides of the canvas. Pinning the text will mean it always maintains the same distance from the canvas's border.
Now we'll make the color of the frame change in response to a tap on the screen of the device.
You've already created the frame_color_mat patch. Create the other 3 patches by right-clicking anywhere in the Patch Editor, and choosing them from the menu. Select:
You'll add the colors to the Option Picker. First change the Option Picker's data type to Color:
To add the colors, click the squares in the Option Picker. Choose a color for each one from the menu:
You can test the effect in the Simulator, by clicking the gear and selecting Simulate Touch:
You've now completed the holiday photo effect!