EnvironmentLightingConfigurationComponent not working

Has anyone gotten EnvironmentLightingConfigurationComponent to work?

I tried the code from https://developer.apple.com/documentation/realitykit/environmentlightingconfigurationcomponent to prevent a planet from being lit by the environment. My goal is that the side that isn't lit by the star appears pitch black. However, the code seems to have no effect on visionOS 2 and iPadOS 18 (I tried betas 1 through 4, on device, built with Xcode 16 beta 4).

No matter if there is a PointLight or no light at all in the scene, no matter if I use SimpleMaterial or PhysicallyBasedMaterial, no matter if I use a texture or a color on the sphere.

I filed a bug report, it's FB14470954.

Or am I doing something wrong? Here's my code:

var material = PhysicallyBasedMaterial()
if let tex = try? await TextureResource(named: "planet.jpg")
{
	material.baseColor = .init(texture: .init(tex))
	material.emissiveIntensity = 0
				
	let sphereMesh = MeshResource.generateSphere(radius: 0.5)
	let entity = ModelEntity()
	entity.components.set(ModelComponent(mesh: sphereMesh, materials: [material]))
	entity.position = [-1, 1.0, -1.0]
				
	let envLightingConfig = EnvironmentLightingConfigurationComponent(environmentLightingWeight: 0)
	entity.components.set(envLightingConfig)
	content.add(entity)
}
Answered by DTS Engineer in 797154022

Hello @Vielfalt,

EnvironmentLightingConfigurationComponent only has an effect on the lighting provided by VirtualEnvironmentProbes, RealityKit configures some of these probes automatically, for example in mixed immersion it automatically uses the environment lighting information from ARKit to configure a probe.

The lighting in your example is provided by the default IBL. To disable that, you can add the following:

let ibl = ImageBasedLightComponent(source: .none)
let iblEntity = Entity()
iblEntity.components.set(ibl)
content.add(iblEntity)
                
let iblReceiver = ImageBasedLightReceiverComponent(imageBasedLight: iblEntity)
entity.components.set(iblReceiver)

Best regards,

Greg

Accepted Answer

Hello @Vielfalt,

EnvironmentLightingConfigurationComponent only has an effect on the lighting provided by VirtualEnvironmentProbes, RealityKit configures some of these probes automatically, for example in mixed immersion it automatically uses the environment lighting information from ARKit to configure a probe.

The lighting in your example is provided by the default IBL. To disable that, you can add the following:

let ibl = ImageBasedLightComponent(source: .none)
let iblEntity = Entity()
iblEntity.components.set(ibl)
content.add(iblEntity)
                
let iblReceiver = ImageBasedLightReceiverComponent(imageBasedLight: iblEntity)
entity.components.set(iblReceiver)

Best regards,

Greg

EnvironmentLightingConfigurationComponent not working
 
 
Q