<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/ARView/PostProcessContext",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:10RealityKit6ARViewC18PostProcessContextV"
  },
  "title" : "ARView.PostProcessContext"
}
-->

# ARView.PostProcessContext

An object the framework uses to pass data to a postprocess callback.

```
struct PostProcessContext
```

## Overview

In iOS 15 and later, as well as macOS 12 and later, you can register a callback function to apply
postprocessing effects to RealityKit’s rendered scene. Once every frame, RealityKit calls that
function before it displays the scene. You can use this callback to apply postprocess effects using
any APIs that can modify an image texture. However, because RealityKit calls this method every
frame, you should only use APIs that execute on the GPU, such as Metal compute functions,
<doc://com.apple.documentation/documentation/MetalPerformanceShaders>,
or <doc://com.apple.documentation/documentation/CoreImage>. You can also render additional
content, such as a rendered SpriteKit scene, on top of the frame buffer.

> Note: For more information on implementing postprocess effects, see
> <doc://com.apple.documentation/documentation/RealityKit/implementing-special-rendering-effects-with-realitykit-postprocessing>,
> which demonstrates multiple postprocess techniques.

A postprocess callback takes a single `PostProcessContext` parameter, which contains
data the callback function needs to modify the rendered scene, including the frame buffer, depth
map, and a property for writing the modified image. If you’ve registered a postprocess callback,
that function needs to encode to the output texture or the frame is never displayed.

A postprocess function looks like this:

```swift
    func myPostProcessCallback(context: ARView.PostProcessContext) {
        // Handle postprocessing here.
    }
```

To register a function as the postprocess render callback, assign it to the
[`postProcess`](/documentation/RealityKit/ARView/RenderCallbacks-swift.struct/postProcess) property of the
[`renderCallbacks`](/documentation/RealityKit/ARView/renderCallbacks-swift.property)  property of the scene’s `ARView`:

```swift
arView.renderCallbacks.postProcess = myPostProcessCallback
```

To stop postprocessing, set the [`postProcess`](/documentation/RealityKit/ARView/RenderCallbacks-swift.struct/postProcess)
render callback to `nil`.

```swift
arView.renderCallbacks.postProcess = nil
```

If your app turns postprocessing on and off frequently, another option for disabling postprocess
effects is to keep your callback registered, but use an <doc://com.apple.documentation/documentation/Metal/MTLBlitCommandEncoder>
to encode the unmodified framebuffer directly to the output texture whenever postprocess effects
aren’t active.

```swift
 func myPostProcessCallback(context: ARView.PostProcessContext) {
     if (usePostProcessEffects) {
         handlePostProcessing(context: ARView.PostProcessContext)
         return
     }


     // If postprocess effects are disabled, copy sourceColorTexture
     // directly to targetColorTexture.
     let blitEncoder = context.commandBuffer.makeBlitCommandEncoder()
     blitEncoder?.copy(from: context.sourceColorTexture, to: context.targetColorTexture)
     blitEncoder?.endEncoding()
 }
```

---

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)