RealityKit - Shadows on placement of AnchorEntity

Hello!
When I expand the AnchorEntity in the following way, I see a shadow falling from the object:
Code Block swift
let anchorEntity = AnchorEntity (plane: .any)
anchorEntity.addChild (parentEntity)

but in my scenario it is necessary to work with ARAnchors in the session (I am implementing a multi-user session and it is necessary to operate on CollaborationData, which, as I understand it, is currently impossible without binding to ARAnchors) and I am trying to write the code like this:
Code Block swift
let anchorEntity = AnchorEntity (plane: .any)
anchorEntity.anchoring = AnchoringComponent (anchor)
anchorEntity.addChild (parentEntity)

or easier
Code Block swift
let anchorEntity = AnchorEntity (anchor: anchor)
anchorEntity.addChild (parentEntity)

then there is no shadow from the placed object.

I figured that the bottom of my object (AnchorEntity) could be placed below the level of the detected flatness and tried to add a few centimeters on the Y axis when calculating the placement point:
Code Block swift
let newTranslate = SIMD4 <Float> (x: transform.columns.3.x, y: transform.columns.3.y + 0.10, z: transform.columns.3.z, w: transform.columns.3.w)
let anchorTransform = simd_float4x4 (columns: (transform.columns.0, transform.columns.1, transform.columns.2, newTranslate))
let anchor = ARAnchor(name: arAnchorName, transform: anchorTransform)
self.arSession.add(anchor: anchor)

This actually lifts my model up 10 centimeters when placed, but there is still no shadow.

Thanks for any help!

Accepted Reply

Answer from technical support:
Hello Dmitry,

Thank you for contacting Developer Technical Support with this incident.

The only way to get the automatic grounding shadow in RealityKit is to use the “plane” AnchoringComponent.Target. If you use the “anchor” AnchoringComponent.target, you will not receive the automatic grounding shadow on your content, even if it is an ARPlaneAnchor.

You can add your own grounding shadow by using a DirectionalLight with a Shadow and placing a plane beneath your model with an OcclusionMaterial, but you may not be able to achieve the same exact look as the automatic grounding shadows with this approach.

I recommend that you file an enhancement request for expanded automatic grounding shadow support for more Target types using Feedback Assistant.

Best regards,


Greg Chiste

DTS Engineer
 Worldwide Developer Relations
  • Yep - same problem - no solution. Currently in the too difficult box. The big elephant in the room is that there are two systems and you have to fight one too get the features from the other - world save/load for example. I keep wondering whether to drop RealityKit as it still hasn't caught up with ARKit in a number of vital areas. The other big issue is that there is no Model I/O to RealityKit mechanism. I had to write my own in the end and the documentation for custom meshes etc for RealityKit is genuinely non-existent!

    Where am I going with this? Oh Yes.

    I really hope that RealityKit 3 deals with a lot of this - when you try to do real work with it there are some howling gaps.

Add a Comment

Replies

Answer from technical support:
Hello Dmitry,

Thank you for contacting Developer Technical Support with this incident.

The only way to get the automatic grounding shadow in RealityKit is to use the “plane” AnchoringComponent.Target. If you use the “anchor” AnchoringComponent.target, you will not receive the automatic grounding shadow on your content, even if it is an ARPlaneAnchor.

You can add your own grounding shadow by using a DirectionalLight with a Shadow and placing a plane beneath your model with an OcclusionMaterial, but you may not be able to achieve the same exact look as the automatic grounding shadows with this approach.

I recommend that you file an enhancement request for expanded automatic grounding shadow support for more Target types using Feedback Assistant.

Best regards,


Greg Chiste

DTS Engineer
 Worldwide Developer Relations
  • Yep - same problem - no solution. Currently in the too difficult box. The big elephant in the room is that there are two systems and you have to fight one too get the features from the other - world save/load for example. I keep wondering whether to drop RealityKit as it still hasn't caught up with ARKit in a number of vital areas. The other big issue is that there is no Model I/O to RealityKit mechanism. I had to write my own in the end and the documentation for custom meshes etc for RealityKit is genuinely non-existent!

    Where am I going with this? Oh Yes.

    I really hope that RealityKit 3 deals with a lot of this - when you try to do real work with it there are some howling gaps.

Add a Comment