From the course: AR Development Techniques 02: Lighting and Physics

Point clouds and plane detection

From the course: AR Development Techniques 02: Lighting and Physics

Start my 1-month free trial

Point clouds and plane detection

- [Instructor] In the previous course we saw how to add a simple floating virtual Earth object in our environment. That was a very straightforward process. Now, what if we want to anchor our place virtual objects on real world surfaces, such as the floor or the table? For that, our app has to first identify the surfaces present in our environment. We have done the basic AR setup, in the previous video, by adding AR Session and AR Session Origin. So if we run the app right now we will just see a blank camera feed but our app is actively identifying unique features and services present in our environment. It's just that we cannot see that process. To visualize that, we will have to enable point clouds and plane visualizers in our project. When we will enable the point clouds and plane visualizers, this is what we will see. When we move the device in our environment, it tries to figure out unique features present in the environment around us and present those features with these little yellow dots. When multiple points are present on one surface, at the same depth, then that is considered to be a plane surface, and our AR app draws these polygon plane visualizers to represent that surface. However, not all plane surfaces are detected by our app. So for example, if our app sees a solid colored white wall which doesn't have any texture then it won't be able to recognize any features and hence it won't overly any polygonal plane visualizers. Another scenario can be when the lighting in our environment is too low and the camera isn't able to see any unique features and planes, in that case also, it will be hard to recognize features and surfaces. So let's see how to enable point clouds and plane visualizers. We need two scripts in our scene. One for enabling point clouds and the other one for plane visualizer. These scripts are provided by the AR Foundation package. So we just have to add them inside our scene. Let's add them on the AR Session Origin object. So add component, we need AR Point Cloud Manager script. And for this, we need a prefab. AR Foundation provides an AR Point Cloud game object. So right-click in the hierarchy, XR and we need AR Default Point Cloud. Create this into a prefab. And let's add this prefab to the script. So drag this right here. Now let's add the AR Plane Visualizers script AR Plane Manager. We need a prefab for this as well. Right-click in the hierarchy, XR, and we need AR Default Plane. Create this into a prefab. And drag this right here. Now the AR Plane Managers script also has this detection mode option. So you can choose what you want to detect. Right now it's set to everything. You can change it to either vertical plane detection, horizontal plane detection, or both or nothing as well. We let it remain as everything. And we can delete these two objects because we have the prefabs. Right-click, delete, delete. In the next video, we'll run the app on the iOS and Android devices. So if you already know how to deploy the app, you can skip the next video.

Contents