RealityKit's custom light entity causes a black artifact on my 3D model

1 week ago 12
ARTICLE AD BOX

I’m working with RealityKit and I’m seeing a strange black artifact appear in the center of my rendered model. Here’s the relevant code:

let camera = PerspectiveCamera() camera.transform = Transform(pitch: -Float.pi / 2, yaw: 0, roll: 0) camera.position = SIMD3<Float>(5, 5, 5) anchor.addChild(camera) let light = DirectionalLight() light.transform = camera.transform anchor.addChild(light) let model = try! await ModelEntity(named: "lightning.usdz") model.position = SIMD3<Float>(5, 3, 5) anchor.addChild(model)

There's a black artifact at the center of the screen (see the tiny dot at the center of the model in the screenshot).

I can confirm that I am using the same lightning.usdz file from my SceneKit app which was rendering fine. This only appears when I migrate to RealityKit. So the USDZ file should be fine. The issue is in RealityKit.

You can download my project here: https://drive.google.com/file/d/1K4m0g84fDJ3_rT8TKFM92jmawTKjYXfG/view?usp=sharing

I can confirm this is related to the custom light entity, because when I set light's intensity to 0, the artifact is gone (of course I can't just use the default lighting for my game, I have to use my custom lighting).

light.light.intensity = 0

enter image description here

Read Entire Article