Objective
Set up Vuforia Smart Terrain feature in Unity.
Introduction
The Smart Terrain feature in Vuforia builds a 3D model of the environment, so objects in the environment can interact with the virtual objects in your scene in a more realistic manner. For example, if a physical object is in front of a virtual object, you want the physical object to block the view of the virtual object.
Prerequisites
Set up the Unity project described in Augmented Reality with Unity, Vuforia, and Google VR. This post adds more features on top of that project.
Steps
Start with the project created in the previous post, as described in the prerequisites section.
Under the Project tab, find Smart Terrain
Drag and drop Smart Terrain on the scene
The Primary Surface and Prop Template will be displayed. These represent the 3D features Smart Terrain will detect in the physical environment.
Select ARCamera. Change the World Center Mode to “Specific Target” and World Center to “Primary Surface”.
Select Image Target and find Image Target Behavior. Enable Smart Terrain. Select the Smart Terrain instance in your scene.
Open Vuforia Configuration and find Smart Terrain Tracker. Select Start Automatically. With this option, scanning of the environment will start automatically when the application is launched.
Set the scale (100 in the example). The scale determines the relative size of the virtual world and the physical world.
Build and run the application on your favorite device.
When Vuforia detects the Image Target it will start scanning the environment to build a 3D model of it. Scan your camera around the environment slowly to capture the different angles of the objects.
Once objects are detected and modeled, try to move a physical object in front of your virtual object to test the effect. Make sure not to cover the Image Target, otherwise the virtual object will disappear.
Useful Links
Vuforia Smart Terrain Tutorial – Augmented Reality in Unity
Very useful YouTube video introducing Smart Terrain in Unity.
Leave a Reply