ARKit crash with automatic environmentTexturing

Hi,

I'm trying to use the new (iOS12) automatic environmentTexturing feature in ARWorldTrackingConfiguration:


let configuration = ARWorldTrackingConfiguration()
configuration.environmentTexturing = .automatic

It works as long as I don't try to use any MTLTextures, so for exmple:


let plane = SCNNode(geometry: SCNPlane(width: 0.5, height: 0.5))
plane.simdPosition = simd_float3(0, 0, -0.5)
plane.geometry?.firstMaterial?.lightingModel = .physicallyBased
plane.geometry?.firstMaterial?.diffuse.contents = UIImage(named: "whatever")
plane.geometry?.firstMaterial?.metalness.contents = 1.0
scene.rootNode.addChildNode(plane)


This works. But if I try to assign contents from a metal texure:


let textureURL = Bundle.main.url(forResource: "sometexture", withExtension: "jpg")
let texture = try? loader.newTexture(URL: textureURL!, options: [:])
...
plane.geometry?.firstMaterial?.diffuse.contents = texture

It crashes with the following error:


failed assertion `Fragment Function(commonprofile_frag): incorrect type of texture (MTLTextureTypeCubeArray) bound at texture binding at index 4 (expect MTLTextureTypeCube) for u_radianceTexture[0].'


Turning off envirnmentTexturing makes it work again:


configuration.environmentTexturing = .none

Is this a bug or am I doing something wrong?

Replies

Works in Beta 4. Must've been a bug.