SKEffectNode Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/SpriteKit.framework
Availability
Available in iOS 7.0 and later.
Companion guide
Declared in
SKEffectNode.h

Overview

An SKEffectNode object applies a Core Image filter to its rendered output, allowing you to incorporate sophisticated special effects in a scene.

To use an effect node, set the effect node’s filter property to point to a Core Image filter and then enable the filter by setting the shouldEnableEffects property to YES. When effects are enabled, the effect node renders its children to an image, applies the filter to it, and then blends the filtered image into the parent’s framebuffer.

Tasks

Enabling Filter Effects

Configuring the Filter

Blending the Results to the Framebuffer

Caching the Filter Results

Properties

blendMode

The blend mode used to draw the filtered image into the parent’s framebuffer.

@property(nonatomic) SKBlendMode blendMode
Discussion

The default value is SKBlendModeAlpha.

Availability
  • Available in iOS 7.0 and later.
Declared In
SKEffectNode.h

filter

The Core Image filter to apply.

@property(retain, nonatomic) CIFilter *filter
Discussion

The Core Image filter must have a single inputImage parameter and produce a single outputImage parameter. The default value is nil. If the value is nil and the effect node is enabled, no filtering takes place. However, its children are still rendered in a separate pass and blended to the parent’s framebuffer.

Availability
  • Available in iOS 7.0 and later.
Declared In
SKEffectNode.h

shouldCenterFilter

A Boolean value that determines whether the effect node automatically sets the filter’s image center.

@property(nonatomic) BOOL shouldCenterFilter
Discussion

If the value of this property is YES and the filter has an inputCenter parameter, then the effect node automatically sets the filter’s input center to the effect node’s origin. The default value is YES.

Availability
  • Available in iOS 7.0 and later.
Declared In
SKEffectNode.h

shouldEnableEffects

A Boolean value that determines whether the effect node applies the filter to its children as they are drawn.

@property(nonatomic) BOOL shouldEnableEffects
Discussion

If the value of this property is YES, then the effect node applies the filter and blends the results. If the value is NO, then the effect node is ignored and its children are rendered normally. The default value is NO.

Availability
  • Available in iOS 7.0 and later.
Declared In
SKEffectNode.h

shouldRasterize

A Boolean value that indicates whether the results of rendering the child nodes should be cached.

@property(nonatomic) BOOL shouldRasterize
Discussion

If the value of this property is YES, the effect node caches the filtered image for use in future frames. If the value is NO, then Sprite Kit discards the rendered image and redraws it from scratch the next time the node is rendered. The default value is NO. Caching the rendered image uses more memory and may take more time to render. However, if the effect node’s descendants rarely change, caching can improve performance.

When caching is enabled, changes to the effect node’s children automatically update the cached image in the next frame of animation. However, changing the filter’s properties does not.

Availability
  • Available in iOS 7.0 and later.
Declared In
SKEffectNode.h