SKLightNode didn't light other nodes anymore?

I don't know since which IOS version but when I use a SKLightNode now then other notes with the same lighting mask are simply black. Only the ambient color has an effect but the color and falloff parameters didn't light the node as expected.


This is the case when I use the game-scene editor or add all sources programmatically.


Source to create light:

        let light = SKLightNode()
        light.falloff = 0.5
        light.name = "Lights"
        light.lightColor = UIColor.white
        light.ambientColor = UIColor.darkGray
        light.categoryBitMask = 1
        self.addChild(light)


Source to create sprite note:

        let wall = SKSpriteNode(imageNamed: "SingleWall6")
        wall.lightingBitMask = 1
        self.addChild(wall)


What do I wrong? Or which other parameters, concepts I have to use?

Replies

Not sure if this is similar to what you see, but iOS 11 beta SKLightNode ambientColor seems to be broken (or at least behaves quite differently compared to iOS 10).


For example, with the following SKLightNode definition, sprites that are normalMapped with lightingBitMask = 1 appear dark/black on iOS 11 whereas they are properly illuminated (brighter) on iOS 10:


let lightSpriteCenter = SKLightNode()

lightSpriteCenter.lightColor = UIColor.white

lightSpriteCenter.isEnabled = true

lightSpriteCenter.categoryBitMask = 1

lightSpriteCenter.ambientColor = UIColor.black

lightSpriteCenter.zPosition = lightZPos

lightSpriteCenter.position = center

lightSpriteCenter.falloff = CGFloat(2)

lightParent.addChild(lightSpriteCenter)


Note, changing ambientColor to UIColor.white makes sprites that are brightly illuminated in both iOS 11 and iOS 10 (but bright illumination isn't the effect I am trying to achieve...I want a gloomy dark effect where illumination is right and drops off quickly). So it seems like a bug in iOS 11. At a minimum, behavior of ambientColor is totally different in iOS 11 compared to iOS 10.

Yes, seems to be the same issue. The color of the light (in your example also white) has no influence, only the ambient color light up. But thats not what we both wanted.

Filed bug, https://bugreport.apple.com/web/?problemID=33378960

Looks like this has been fixed in the latest betas.