Hand tracker: Calibration and occlusion

Before using the hand tracker, we should calibrate it. We'll also occlude AR assets that appear behind the hand.

Calibration

The hand tracker can sometimes project the hand landmarks into the wrong depth range. A calibration process is required to fix this error. It's a short process where we ask the user to place their hand on a flat surface, direct the camera on it and bring it closer and further for a few seconds while a plane ray-casting is performed to determine the distance from the camera to the plane on which the user has laid the hand. In the demo scene from the sample provided with the Ur package, you can find a Calibrate Hand Tracker Button and code that can easily be used in any project.

You will also need to add the ^ARPlaneManager^ component on the ^ARSessionOrigion^ GameObject.

Occlusion Culling

Add the ^AROcclusionManager^ component to ^AR Camera^ GameObject and adjust its properties (Fastest on all).

To use the ^AROcclusionManager^ in the code, import ^ARSubsystems^.

using UnityEngine.XR.ARSubsystems;

Declare an ^AROcclusionManager^ serializable variable and a boolean for toggling it on and off.

[SerializeField] private AROcclusionManager arOcclusionManager;
private bool occlusionBool = true;

In Unity, drag the ^ARCamera^ GameObject to the ^AROcclusionManager^ field in the ^ConureKitManager^.

Then create a toggle method to toggle between the different ^AROcclusionManager^ modes.

public void ToggleOcclusion()
{
    occlusionBool = !occlusionBool;

    arOcclusionManager.requestedHumanDepthMode = occlusionBool ? HumanSegmentationDepthMode.Fastest : HumanSegmentationDepthMode.Disabled;
    arOcclusionManager.requestedHumanStencilMode = occlusionBool ? HumanSegmentationStencilMode.Fastest : HumanSegmentationStencilMode.Disabled;
    arOcclusionManager.requestedEnvironmentDepthMode = occlusionBool ? EnvironmentDepthMode.Fastest : EnvironmentDepthMode.Disabled;
}

Use a UI toggle to switch between modes, but again you can use any method you choose.

Need a refresher on the essentials?

Check out more lessons, DIY kits and essentials reading material at the developer learning centre homepage.

想在 posemesh 上进行建设,需要帮助吗?

申请 AUKI 代币补助金以启动您的项目,并直接与 Auki Labs 团队合作,将您的创意推向市场。成功申请者可获得价值高达 10 万美元的 AUKI 代币,以及 Auki Labs 团队提供的开发和营销支持。