---
title: "encodeRender(to:frameAttributes:sourceImage:sourceDisparity:destinationImage:)"
framework: Cinematic
role: symbol
role_heading: Instance Method
platforms: [iOS 27.0+, iPadOS 27.0+, macOS 27.0+, tvOS 27.0+]
path: "cinematic/cnrenderingsession-1hzh8/encoderender(to:frameattributes:sourceimage:sourcedisparity:destinationimage:)-3rknf"
---

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

Encode a command to render a shallow depth of field (SDoF) image to a pixel buffer.

## Declaration

```swift
func encodeRender(to commandBuffer: any MTLCommandBuffer, frameAttributes: CNRenderingSession.FrameAttributes, sourceImage: CVReadOnlyPixelBuffer, sourceDisparity: CVReadOnlyPixelBuffer? = nil, destinationImage: CVPixelBuffer) -> 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.
- `destinationImage`: The pixel buffer to which the SDoF image is rendered

## Return Value

Return Value Whether encoding the render command was successful
