Everything you need to know to create an interactive augmented reality experience.
Learn to create the Holiday Photo 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 in your own projects.
You'll learn about:
You can also find out what's in the finished effect.
If you want to build this effect yourself, 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.
To get started, add the objects to the scene. We're going to add them all 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 tab, create 2 more.
To keep track of layers, it's a good idea to rename them. We've called:
In the Inspector, change the Render Mode for 2 of the layers. Change:
Back in the Scene tab, 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 panel, 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 means we can change its Transformations in the Inspector panel. 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. 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 panel.
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.
Overlay_mat changes color when the screen is tapped. You'll use the Patch Editor to do this. Start by creating clicking the small circle next to Texture. This will make a patch representing the Diffuse Texture property of the material. We'll add the rest of the patches later.
At this point, your project should look like this:
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 to choose from when creating your own effects.
You'll see the text is in the middle of the frame. Click Fill Parent to make the text object 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.
We used the Patch Editor to build a really simple graph, with 4 patches:
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 To do this, you'll need to change the Type to Color:
To add the colors, click the input circles in the Option Picker. Choose a color for each one.
In the Counter patch, set the Maximum Count to 5, because we want to count through 5 different colors. The counter will then reset to zero.
Connect the Tap output in the Screen Tap patch to the Increase input in the Counter patch.
You can test the effect in the Simulator, by clicking the gear and selecting Simulate Touch:
You've now completed the holiday photo effect!
Find out what's happening in the finished effect.
There are 3 objects under a canvas in the Scene tab - 2 rectangles and a text object. Each rectangle has a material applied to it.
frame_mat - this material has a custom texture, frame_tex applied to it to create the appearance of the outside of the photograph. We applied it to the first rectangle in the scene, rect_frame.
frame_color_mat - this material creates the appearance of the colored overlay that covers the inside of the frame. We used options in Spark AR Studio to define its color. It's applied to the second rectangle, rect_overlay.
frame_tex is the custom texture we've applied to the frame material.
Find inspiration, see examples, get support, and share your work with a network of creators.Join Community