SKCropNode does not mask SKEffectNode

Originator:sartak
Number:rdar://16534194 Date Originated:2014-04-05
Status:Duplicate of 13774565 Resolved:
Product:iOS SDK Product Version:7.1
Classification:UI Reproducible:Always
 
Summary:
When an SKEffectNode is inside an SKCropNode, the SKCropNode's maskNode does not mask the SKEffectNode.

Setting `shouldEnableEffects` to NO, or `shouldRasterize` to YES, causes the SKEffectNode to be correctly masked.

Steps to Reproduce:
1. Add an SKEffectNode to an SKCropNode.
2. Add a maskNode to the SKCropNode.

Create a new iOS Xcode project (or use the attached tarball) using the Sprite Kit template. Replace the scene class's implementation with the following code. Note the if-statements inviting you to test the two workarounds.


-(id)initWithSize:(CGSize)size {    
    if (self = [super initWithSize:size]) {
        CGPoint center = CGPointMake(size.width / 2, size.height / 2);

        SKCropNode *crop = [SKCropNode node];

        SKSpriteNode *mask = [SKSpriteNode spriteNodeWithColor:[SKColor whiteColor] size:CGSizeMake(200, 200)];
        mask.position = center;
        crop.maskNode = mask;

        // this sprite is added to confirm that the SKCropNode is functioning correctly
        SKSpriteNode *red = [SKSpriteNode spriteNodeWithColor:[SKColor colorWithRed:1 green:0 blue:0 alpha:0.5] size:size];
        red.position = center;
        [crop addChild:red];

        SKEffectNode *effect = [SKEffectNode node];
        [crop addChild:effect];

        SKSpriteNode *green = [SKSpriteNode spriteNodeWithColor:[SKColor colorWithRed:0 green:1 blue:0 alpha:0.5] size:size];
        green.position = center;
        [effect addChild:green];

        if (0) {
            effect.shouldEnableEffects = NO;
        }
        else if (0) {
            effect.shouldRasterize = YES;
        }

        [self addChild:crop];
    }
    return self;
}


Expected Results:
The SKEffectNode should be masked by the SKCropNode.

Actual Results:
The SKEffectNode is not masked by the SKCropNode.

Version:
iOS 7.1 (11D167)

Notes:


Configuration:
iPhone 5S
iOS Simulator

Comments

sartak

This is still occurring with iOS 8 beta (Build 12A4265u). The two workarounds I offered do still restore the cropping, but obviously they are not ideal.

sartak

Attached a sample Xcode project to demonstrate the problem.

Note the if-statements on RPGMyScene.m's lines 35 and 38 inviting you to test the two workarounds. These workarounds severely reduce the usefulness of SKEffectNode, but they do cause the cropping to work correctly.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!