SCNlight categoryBitMask is broken in iOS 12 Beta

Assigning a categoryBitMask to a SCNlight in iOS 12 (beta 3 & 4) has no effect. It works on the simulator but when running on an actual device its broken.

The following code is a simple example showing whats wrong.

Since the categoryBitMask for the light is different from the ball, the light should not light up the ball and the scene should be dark. But when we run this code on an actual device the ball is lit.


struct Mask {
    static let mask1:Int = 0b1
    static let mask2:Int = 0b10
    static let mask3:Int = 0b100
    static let mask4:Int = 0b1000
}

class GameViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let scene = SCNScene()
        
        // Add Camera
        let cameraNode = SCNNode()
        cameraNode.camera = SCNCamera()
        cameraNode.position = SCNVector3(x: 0, y: 0, z: 2)
        scene.rootNode.addChildNode(cameraNode)
        
        // Add ball
        let ball = SCNSphere(radius: 0.1)
        ball.firstMaterial?.diffuse.contents = UIColor.white
        let ballNode = SCNNode(geometry: ball)
        scene.rootNode.addChildNode(ballNode)
        
        // Add light
        let lightNode1 = SCNNode()
        lightNode1.light = SCNLight()
        lightNode1.light!.type = .directional
        lightNode1.light!.color = UIColor.yellow
        lightNode1.light?.castsShadow = true
        lightNode1.position = SCNVector3(x: 0, y: 10, z: 10)
        lightNode1.light?.categoryBitMask = Mask.mask2
        scene.rootNode.addChildNode(lightNode1)
        
        let scnView = self.view as! SCNView
        scnView.scene = scene
    }
}


Is there any other way I can use to exclude a light shining on a node until apple fixes this issue?


Thanks

Replies

Make sure you file a bug report about this using our bug reporting system at https://developer.apple.com/bug-reporting/

Koushan, I've felt your pain since iOS 12b1 with the very same problem. When I filed a bug report about my own SCNLight categoryBitMask issues, I was soon informed that my submission was a dup. At least Apple's SceneKit team is aware of this issue, so hopefully it will have it fixed soon.