将CIFilter与SKScene合成

时间:2014-07-16 17:00:27

标签: ios sprite-kit blending cifilter skscene

我试图在图像上使用颜色躲闪混合模式(CIFilter)并将其与我的整个场景(这是一个SKScene节点)合成。不幸的是,CIColorDodgeBlendMode只将CIImage作为Background的输入。可能有解决方法吗?

基本上我想要相同的结果,比如Photoshop中有2层,上层应用了颜色躲闪混合模式。

这是我的代码(' self'将是SKScene节点):

UIImage *inputUIImage = [UIImage imageNamed:@"inputImage.png"];
CIImage *inputCIImage = [[CIImage alloc]initWithImage:inputUIImage];

CIFilter *filter = [CIFilter filterWithName:@"CIColorDodgeBlendMode"];
[filter setValue:inputCIImage forKey:@"inputImage"];
[filter setValue:self forKey:@"inputBackgroundImage"];

CIImage *outputImage = [filter outputImage];
CIContext *context = [CIContext contextWithOptions:nil];
CGImageRef cg = [context createCGImage:outputImage fromRect:[outputImage extent]];
SKTexture *outputTexture = [SKTexture textureWithCGImage:cg];

SKSpriteNode * outputSprite = [[SKSpriteNode alloc]initWithTexture:outputTexture];
[self addChild:outputSprite];

0 个答案:

没有答案