RealityKit – How to create shadow catcher for natural lighting?

Viewed 192

I'd like to create a plane:

func getShadowPlane(_ width: Float, _ height: Float) -> ModelEntity {

    let sphereResource = MeshResource.generatePlane(width: width, 
                                                    depth: height)
    let myMaterial = ShadowMataerial . ????
    return ModelEntity(mesh: sphereResource, materials: [myMaterial])
}

& add it to my anchor at specific position. I'd like to get shadow data from the "lighting" I get from my camera that RealityKit is able to capture/generate.

I don't want to use

AnchorEntity(plane: AnchoringComponent.Target.Alignment.horizontal)

Any idea how can this be accomplished?

I can not find shadowCatcher material.

1 Answers

I'm afraid there's NO formula for catching only shadows in RealityKit 2.0, like SceneKit's:

SCNMaterial().lightingModel = .shadowOnly

However, you can use Fake Shadows based on .png image or you can implement Metal to separately catch a shadow.

Related