<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "tvOS: -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "SpriteKit",
  "identifier" : "/documentation/SpriteKit/SKEffectNode/filter",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SpriteKit"
    ],
    "preciseIdentifier" : "c:objc(cs)SKEffectNode(py)filter"
  },
  "title" : "filter"
}
-->

# filter

The Core Image filter to apply.

```
var filter: CIFilter? { get set }
```

## 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.

If you wish to use a Core Image filter that doesn’t have an `inputImage` parameter, such as a sunbeams generator, you can subclass <doc://com.apple.documentation/documentation/CoreImage/CIFilter-swift.class> and add an `inputImage` property. The input image’s extent can be used to define properties such as radius on the filter. The following code creates a filter based on [CISunbeamsGenerator](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Reference/CoreImageFilterReference/index.html#//apple_ref/doc/filter/ci/CISunbeamsGenerator) which can be used as an effect node’s filter:

```objc
class StarGenerator: CIFilter {    
    var inputImage: CIImage?        
    override var outputImage: CIImage? {        
        guard let inputImage = inputImage else {            
            return nil        
        }                
        let extent = inputImage.extent                
        let center = CIVector(x: extent.midX, y: extent.midY)                
        let starShineGenerator = CIFilter(            
            name: "CISunbeamsGenerator",            
            withInputParameters: [                
                "inputMaxStriationRadius": 2,                
                "inputSunRadius": extent.midX / 2,                
            kCIInputCenterKey: center])                
        return starShineGenerator!.outputImage?.cropping(to: extent)    
    }
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)