Place virtual object in VR with occlusion

Hi, I am new to iOS ARKit. I tried some sample code and placed virtual 3D model in VR. It looked like however there was no occlusion in ARKit. If the 3D model is behind real world objects, it still can been seen.


Am I correct?

Replies

This is correct, ARKit will not automatically occlude your scene with real world objects. If you would like to create occluding geometry for detected geometries in your session (like horizontal or vertical planes for example), you would create a plane using the ARPlaneAnchor's geometry, and then you would only write to the depth buffer (by setting the SCNColorMask of the plane's material to an empty value []), and you would ensure that your plane be rendered before the rest of the content in your scene (by setting the renderingOrder on your plane's node).

About ensuring that you aren't writing to the color buffer:


In Xcode's Scene Editor, you can uncheck the "Write to Color" checkboxes for a particular material in the 'Material Inspector' pane.