Depth Enabled Templates
When available, Lenses can use depth data to enhance the Lens experience--whether it be to occlude content by physical objects, get information about surfaces in the camera, or to create effects that respond to depth. Depth data is currently available on many Android devices through Google’s ARCore Depth API, as well as on Spectacles 3 videos.
To help get you started, you can download the following templates enhanced by depth:
- Depth Toybox Template: Uses the depth data to estimate surface orientation in the scene, as well as occlude AR objects
- Depth Materials Template: Provides 3 different examples of using depth in materials made by Material Editor
- Underwater Depth Template: Demonstrates the usage of depth to create an underwater scene
Tip: Each template comes with several preview videos to test out how your Lens will look. In the
Preview panel, make sure to use the
video preview option, and try your Lens on several videos provided in the project.
Depth Toybox Template
This template provides an example of using depth data to figure out the orientation of surfaces in the scene, as well as how you can use it to occlude your AR objects based on the real world.
The template allows you to select, place, and delete objects in the scene, have the option to spawn objects where you’ve moved them, as well as create additional effects based on the user’s interaction.
Note: This template demonstrates the ability to rotate an object based on the orientation of surfaces in the Camera. However, since it uses touch, it's better suited for the live camera than on Spectacles 3 footage.
The template comes with 4 different example objects which will interact with what the camera sees. Each of these objects utilizes the
Stick to Surfaces
StickToSurfaces script uses the depth data to estimate where a surface might be facing. It then orients the object based on that information. For example, when you drag an object to a wall, it will reorient the object so that the bottom of the object touches the wall. It also provides an additional option to
Make Copies of the object as it is dragged, as well as for it to
Look Towards where the user is dragging the object.
This script also provides the ability for you to define another script to use as
Effect Controllers. Each
Effect Controller can provide additional effects based on the user interaction.
Tip: For each Placeable Object in the examples, you can find an
Effects Control child object. Take a look at the scripts found in these objects for examples of how you can add additional effects.
OcclusionControl script allows you to add references to meshes that you want to occlude based on the depth data. For a mesh to be occluded, it must be using a material that supports occlusion. You can find a material in the Materials folder named
Occluded PBR [DUPLICATE_ME], which is a standard PBR shader with added occlusion effects.
When using the Lens, users can choose between each Placeable Object based on the buttons on the screen.
The images used for the buttons can be set up in the
PlaysetController object. You can further customize the look and feel of the buttons by modifying the
Button Layout object, as well as its children objects under the
UI object in the
Orthographic Camera object.
Depth Materials Template
This template provides different examples of how you can use depth with Material Editor to achieve different effects.
To try each effect, you can enable or disable the checkbox next to the effects name in the
Each example has their own customization. To modify the effect, select the material in the
Resources panel, then in the
Inspector panel, modify its properties. Double-click the material to open it in the Material Editor.
Depth Of Field
Underwater Depth Template
This template uses depth and Material Editor to add caustics on the camera feed. It uses the depth texture in several ways to compose the effect, as well as other Material Editor techniques to complete the experience.
The template first uses Material Editor to generate a caustic texture on a sphere using the
Caustics Sphere material rendered by the
Caustics Camera. Then, it displaces the results of this camera using the
Depth Displacement material. The
Depth Displacement material uses the depth value to change how the results are projected onto the video.
In addition, it uses the depth data on the
Fog material to tint the video the further back in depth it goes.
To complete the underwater feeling, the template uses two techniques. It uses the
Displacement material to add waves onto the screen, as well as several color correction materials to add a blue tint.
Tip: To see how these materials were made, double-click on them in the
Resources panel to open them in Material Editor. Play around with these node graphs to modify and create your own effects!
Still Looking for help?Visit Support