2 Replies
      Latest reply on Jan 5, 2019 3:08 AM by epicurus101
      epicurus101 Level 1 Level 1 (0 points)

        I have two sprites that I want to overlay with standard alpha blending.  However the 'front' sprite is itself derived from a snapshot texture of a node tree that uses subtractive blending.  I wouldn't expect that to make a difference - the SKTexture that comes out has been flattened, hasn't it?  So as long as it's used to create a front sprite that uses normal alpha blending I wouldn't expect a problem.  Except it behaves very oddly.  The following code illustrates the point (it's a simplified version of my code).

                backgroundColor = .black
                let masterNode = SKNode()
                let bground = SKShapeNode(circleOfRadius: 100)
                bground.fillColor = .red
                bground.position.x = -75
                bground.zPosition = -1
                bground.blendMode = .alpha
                let temp1 = SKShapeNode(circleOfRadius: 100)
                temp1.fillColor = .lightGray
                let temp2 = SKShapeNode(circleOfRadius: 50)
                temp2.fillColor = .red
                temp2.blendMode = .subtract
                temp2.zPosition = 1
                let fground = SKSpriteNode(texture: SKView().texture(from: temp1))
                fground.blendMode = .alpha
                masterNode.position.x = UIScreen.main.bounds.width/2
                masterNode.position.y = UIScreen.main.bounds.height/2


        I realise some of these lines are unnecessary, it's just to make clear the blendMode being applied.


        I'm expecting a cyan hole that isn't blended at all with the background because the cyan hole should have alpha values of 1.0.


        It follows that I'm NOT expecting the bground shape to "show through" the hole - but it does.


        Also, I'm definitely not expecting the bground shape to be blending additively with the hole - it's not even demonstrating normal alpha blending.


        Can anyone help me understsand what's going on?