Mobile AR depth mapping can help virtual content respond to the shape and position of physical surroundings. Instead of relying only on detected planes, an application can use camera-based depth data to test for occlusion, estimate surface contact, and render effects that account for scene geometry. The challenge is turning a depth map into useful interaction without requiring developers to build a full 3D reconstruction pipeline.
DepthLab, an open-source library for Unity built around the ARCore Depth API, offers one approach. It organizes depth processing into reusable data structures and algorithms, making geometry-aware features more accessible to mobile AR developers. Its design also provides a useful framework for understanding what different depth representations canâand cannotâsupport.
Why depth maps are more than distance images
A depth map assigns a distance value to image pixels, providing a link between the camera view and the physical scene. Raw measurements alone, however, do not automatically translate into usable 3D interaction. Developers must account for camera parameters, screen orientation, coordinate transformations and gaps or discontinuities in the depth data.
Traditional plane-based AR can place content on a detected floor or tabletop, but a plane is a coarse representation of the environment. It may not describe irregular objects or surface edges accurately. A persistent mesh can support richer interactions, but building and maintaining one can add computation, memory demands and a scanning step before the environment is ready.
DepthLab instead works directly with live depth maps. In its described configuration, depth can be estimated from a moving RGB camera, without requiring a dedicated depth camera or persistent surface reconstruction. The library converts depth into representations suited to specific tasks, rather than treating every feature as a full-scene modeling problem.
Three representations for mobile AR depth mapping
DepthLab groups its processing methods into localized, surface and dense depth. Each has different computational and functional characteristics.
- Localized depth: The application samples a limited number of points from a CPU-side depth array. This suits tasks such as measuring a point in the scene, estimating a surface orientation, performing a hit test or checking a virtual objectâs placement.
- Surface depth: Depth samples are converted into a real-time mesh. This gives graphics and physics systems connected geometry to work with for collisions, physics behavior, shadows and texture effects. The mesh is generated from current depth data rather than maintained as a persistent environmental reconstruction.
- Dense depth: The depth map is made available as a GPU texture for per-pixel processing. This supports screen-space effects such as virtual-object occlusion, relighting and depth-based focus or aperture effects.
The central engineering decision is to match the representation to the feature. A simple point placement check may not need a mesh; a physics interaction needs more surface structure; and a full-screen visual effect is naturally suited to GPU-based depth processing.
From measurements to geometry-aware interaction
Localized depth for hit tests and movement
To use a sampled depth value in a 3D scene, the system maps a screen coordinate into camera space using the cameraâs intrinsic parameters, then transforms the result into world space using the camera pose. Once the physical point and virtual content share a coordinate system, the application can test their relationship.
This supports more detailed interaction than checking only against a detected plane. For example, a virtual cursor can be oriented to a measured surface, or an application can check whether a virtual object intersects the observed environment. Because estimated depth may contain noise or invalid samples, DepthLab describes using multiple-point checks, such as majority voting for placement, rather than relying on one measurement.
Localized depth can also guide an avatar around obstacles. The approach described moves a character across the ground plane, then casts downward along gravity to find a depth-indicated surface and adjust the characterâs position. Filtering is used to reduce visible jitter.
Surface depth for collisions, shadows and decals
A depth mesh turns a grid of measurements into connected triangles that standard graphics and physics tools can process. The mesh is updated from the live depth map, and discontinuities can be excluded so that triangles do not bridge large depth changes. This representation can support collision checks and, with suitable processing, interactions such as virtual objects bouncing from physical surfaces.
Mesh-based geometry also enables effects that need surface information from viewpoints other than the camera, including geometry-aware shadows. Surface depth can also support texture decals or âsplatsâ that appear to wrap onto physical objects. These capabilities depend on the quality and coverage of the depth data; a depth map is a set of measured distances, not a complete volumetric model.
Dense depth for per-pixel rendering
When depth is available as a GPU texture, shaders can compare virtual-object depth with the observed physical scene to produce occlusion. This helps make a virtual object appear behind a real surface when appropriate. DepthLab also describes using ray marching toward virtual light sources to estimate occlusion-aware relighting without depending on a potentially noisy normal map.
Other dense-depth examples include anchoring a focus point to a physical 3D location and varying blur according to distance, rather than locking focus to a screen coordinate. Because source depth maps may have much lower resolution than the display, filtering is important: ordinary upscaling can create visible artifacts, while depth-guided anti-aliasing can smooth depth while respecting boundaries.
Performance and implementation trade-offs
Depth processing is not free, particularly when work runs across every screen pixel. The libraryâs design therefore separates CPU point queries from mesh operations and GPU image effects. Its evaluation on a Pixel 3 reported different processing costs for its sample components and found that relighting quality and aperture blur involved a performance trade-off as sampling or filter sizes increased. Those measurements are specific to the tested device and implementation, not universal performance guarantees.
For engineering teams, the practical lesson is to profile on the target hardware and choose the least complex representation that meets the interaction requirement. Depth quality, device capabilities, frame-time budgets and the visual tolerance for artifacts all influence the result.
What depth-based AR means for developers
Depth maps can add scene awareness without the cost or setup requirements of persistent mesh reconstruction, but they do not eliminate the need for careful integration. Coordinate conversion, noisy boundaries, resolution differences and device performance remain important considerations. DepthLabâs value is its modular structure: it packages common processing steps and example features so developers can build on depth data without implementing every operation from scratch.
For mobile AR projects, the most useful starting point is to define the desired behaviorâplacement, collision, occlusion or a visual effectâthen select localized, surface or dense depth accordingly. That task-first approach keeps processing aligned with application needs and helps teams evaluate accuracy and performance where they matter. The result is a more deliberate path from camera measurements to virtual content that behaves as though it belongs in the physical scene.
Access Official Technical PDF