Mike Koene
Mike Koene

Reputation: 330

ARKit Occlusion Invisible Plane Reference Image

I'm trying to hide SCNPlanes behind an invisible SCNPlane the same size as the ARReferenceImage. Using SCNAction I want to reveal those planes next to the ARReferenceImage

Problem

The SCNPlanes are still visible and not hidden.

This is the code I use for Occlusion:

let plane = SCNPlane(width: referenceImage.physicalSize.width,
                     height:referenceImage.physicalSize.height)
let planeNode = SCNNode(geometry: plane)

planeNode.geometry?.firstMaterial?.writesToDepthBuffer = true
planeNode.geometry?.firstMaterial!.colorBufferWriteMask = .alpha
planeNode.renderingOrder = -1

This is my code: https://gist.github.com/magicmikek/0444fbd5c146131ad08fbb19875fbc83

Upvotes: 1

Views: 347

Answers (1)

Mike Koene
Mike Koene

Reputation: 330

The invisible planeNode can't have the same Y value as the SCNPlanes it wants to hide using occlusion.

Solution

nodeBehind.position.y = -0.005

Upvotes: 2

Related Questions