Spatial Meshing Sample
This sample demonstrates how to generate and visualize the spatial mesh approximating the environment in the real world.
For information about spatial meshing and what AR Foundation's AR Mesh Manager component does, refer to the Unity documentation. Visit the Spatial Meshing feature page for more information about using the Snapdragon Spaces SDK feature.
In order to use this feature it must be enabled in the OpenXR plugin settings located under Project Settings > XR Plug-in Management > OpenXR (> Android Tab).
How the sample works
Attaching the AR Mesh Manager script component to a child of the XR Origin Game Object will enable the meshing subsystem. Upon starting, the subsystem will generate mesh which closely approximates objects found in the real world.
The Spatial Meshing Sample Controller script component in the sample scene handles changes to the UI.
- When the CPU Normals checkbox is checked, Mesh Filter components provided by the
ARMeshManger.meshesChanged
event will have cpu generated normals. Generated meshes are created using the prefab found at Assets > Samples > Snapdragon Spaces > Core Samples > Scenes > Spatial Meshing Sample > Prefabs > MeshPrefabWithCPUNormalsPrefab. This prefab has a Mesh Renderer attached, and draws the mesh using the Mesh With Cpu Normals material. This material uses the Standard shader. - When the CPU Normals checkbox is unchecked, Mesh Filter components provided by the
ARMeshManger.meshesChanged
event will have no normals. Generated meshes are created using the prefab found at Assets > Samples > Snapdragon Spaces > Core Samples > Scenes > Spatial Meshing Sample > Prefabs > MeshPrefab. This prefab has a Mesh Renderer attached, and draws the mesh using the Depth Outline material. This material uses a custom Mesh Visualization shader which generates normals for visualization purposes. - The Mesh Opacity slider controls how see through the rendered mesh is. This value is clamped between 0.1 and 1.0 by the Spatial Meshing Sample Controller script component. A value of 0.1 is very transparent, and a value of 1.0 is completely opaque.