ARKit depth information for virtual objects in scene.

I'm tyring to extract the depth information for my scene only for my virtual objects... not the depthDataMap. In openGL it was pretty easy to get this gray scal map, but I i'm really struggling to find informaiton as to how to do this for my virtual objects. The main objective of this is for me to be able to render out 3D photos for Facebook. Obvioulsy the ARKit depth of field must use something like this to calcualte the blur of scene objects based on distance, however, I'm at a loss as to how to do this with SceneKit/ARKit?

Bump.

This is a really useful feature, that can be done pretty easily in Unity/OpenGL.

I have found this: https://stackoverflow.com/questions/55917084/how-to-extract-scenekit-depth-buffer-at-runtime-in-ar-scene, but there's no elaborate answer or an example that demonstrates how this can be done in SceneKit/RealityKit.

In RealityKit, you can access the depth target pretty easily by using the PostProcessContext:

arView.renderCallbacks.postProcess = { context in

    // Access the depth target here.
    let sourceDepthTexture = context.sourceDepthTexture
}

In SceneKit, things are a bit more complex, you can use an SCNRenderer to render to offscreen render targets, and from there you can access the offscreen depth target that you rendered to.

If you need a more in-depth assistance for either case, please Request Technical Support.

ARKit depth information for virtual objects in scene.
 
 
Q