<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Cinematic",
  "identifier" : "/documentation/Cinematic/CNRenderingSession-1hzh8/encodeRender(to:frameAttributes:sourceImage:sourceDisparity:destinationRGBA:)-1gaox",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Cinematic"
    ],
    "preciseIdentifier" : "s:9Cinematic18CNRenderingSessionC12encodeRender2to15frameAttributes11sourceImage0I9Disparity15destinationRGBASbSo16MTLCommandBuffer_p_AC05FrameH0V9CoreVideo015CVReadOnlyPixelO0CAOSgSo10MTLTexture_ptF"
  },
  "title" : "encodeRender(to:frameAttributes:sourceImage:sourceDisparity:destinationRGBA:)"
}
-->

# encodeRender(to:frameAttributes:sourceImage:sourceDisparity:destinationRGBA:)

Encode a command to render a shallow depth of field (SDoF) image to a metal texture as RGBA.

```
func encodeRender(to commandBuffer: any MTLCommandBuffer, frameAttributes: CNRenderingSession.FrameAttributes, sourceImage: CVReadOnlyPixelBuffer, sourceDisparity: CVReadOnlyPixelBuffer? = nil, destinationRGBA: any MTLTexture) -> Bool
```

## Parameters

`commandBuffer`

the metal command buffer on which to encode the command

`frameAttributes`

controls the focus distance and aperture of the rendering

`sourceImage`

a pixel buffer read from the cinematicVideoTrack

`sourceDisparity`

a pixelbuffer with disparity. Can be nil only when preview rendering of assets before preprocessing (CNAssetInfo.cinematicCapability == .needsPreprocessing). When nil the source disparity and frameAttributes.focusDisparity will be computed internally. Passing nil for other types of assets will return false.

`destinationRGBA`

a metal texture to which the SDoF image is rendered in RGBA format

## Return Value

whether encoding the render command was successful

---

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)