Sceneform Maintained SDK for Android

Depth

Depth

DepthMode

The DepthMode is automatically set based on the Session config.

DepthOcclusionMode

The DepthOcclusionMode can be set by the user.

Examples

@Override
public void onSessionConfiguration(Session session, Config config) {
    if (session.isDepthModeSupported(Config.DepthMode.AUTOMATIC)) {
        config.setDepthMode(Config.DepthMode.AUTOMATIC);
    }
    config.setUpdateMode(Config.UpdateMode.LATEST_CAMERA_IMAGE);
}

@Override
public void onViewCreated(ArFragment arFragment, ArSceneView arSceneView) {
    // By default he occlusion is disabled even if the DepthMode is set to AUTOMATIC or RAW_DEPTH_ONLY
    // Not every Depth use case requires the occlusion feature!
    arSceneView.getCameraStream()
        .setDepthOcclusionMode(CameraStream.DepthOcclusionMode
            .DEPTH_OCCLUSION_ENABLED);
}

Occlusion_AUTOMATIC

@Override
public void onSessionConfiguration(Session session, Config config) {
    if (session.isDepthModeSupported(Config.DepthMode.RAW_DEPTH_ONLY))
        config.setDepthMode(Config.DepthMode.RAW_DEPTH_ONLY);
    config.setUpdateMode(Config.UpdateMode.LATEST_CAMERA_IMAGE);
}

@Override
public void onViewCreated(ArFragment arFragment, ArSceneView arSceneView) {
    // By default he occlusion is disabled even if the DepthMode is set to AUTOMATIC or RAW_DEPTH_ONLY
    // Not every Depth use case requires the occlusion feature!
    arSceneView
        .getCameraStream()
        .setDepthOcclusionMode(CameraStream.DepthOcclusionMode
            .DEPTH_OCCLUSION_ENABLED); // Available modes: DEPTH_OCCLUSION_DISABLED, DEPTH_OCCLUSION_ENABLED
    }

Occlusion_RAW_DEPTH_ONLY

@Override
public void onSessionConfiguration(Session session, Config config) {
    if (session.isDepthModeSupported(Config.DepthMode.DISABLED))
        config.setDepthMode(Config.DepthMode.DISABLED);
    config.setUpdateMode(Config.UpdateMode.LATEST_CAMERA_IMAGE);
}

Occlusion_DISABLED

Any of the following combinations results into the disabled Occlusion use case

@Override
public void onSessionConfiguration(Session session, Config config) {
    if (session.isDepthModeSupported(Config.DepthMode.AUTOMATIC))
        config.setDepthMode(Config.DepthMode.DISABLED);
   config.setUpdateMode(Config.UpdateMode.LATEST_CAMERA_IMAGE);
}
@Override
public void onSessionConfiguration(Session session, Config config) {
    if (session.isDepthModeSupported(Config.DepthMode.RAW_DEPTH_ONLY))
        config.setDepthMode(Config.DepthMode.DISABLED);
    config.setUpdateMode(Config.UpdateMode.LATEST_CAMERA_IMAGE);
}

If the user wants to activate the DepthMode by setting it to AUTOMATIC or RAW_DEPTH_ONLY but is not interested about the occlusion of virtual objects behind real world objects he can set the DepthOcclusionMode value to DEPTH_OCCLUSION_DISABLED.

@Override
public void onViewCreated(ArFragment arFragment, ArSceneView arSceneView) {
    // Currently, the tone-mapping should be changed to FILMIC
    // because with other tone-mapping operators except LINEAR
    // the inverseTonemapSRGB function in the materials can produce incorrect results.
    // The LINEAR tone-mapping cannot be used together with the inverseTonemapSRGB function.
    Renderer renderer = arSceneView.getRenderer();

    if (renderer != null) {
        renderer.getFilamentView().setColorGrading(
            new ColorGrading.Builder()
                .toneMapping(ColorGrading.ToneMapping.FILMIC)
                .build(EngineInstance.getEngine().getFilamentEngine())
        );
    }

    arSceneView
        .getCameraStream()
        .setDepthOcclusionMode(CameraStream.DepthOcclusionMode
            .DEPTH_OCCLUSION_ENABLED); // Available modes: DEPTH_OCCLUSION_DISABLED, DEPTH_OCCLUSION_ENABLED
    }