<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ImmersiveMediaSupport",
  "identifier" : "/documentation/ImmersiveMediaSupport/ImmersivePreviewRenderer",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Immersive Media Support"
    ],
    "preciseIdentifier" : "s:21ImmersiveMediaSupport0A15PreviewRendererC"
  },
  "title" : "ImmersivePreviewRenderer"
}
-->

# ImmersivePreviewRenderer

An object that renders an immersive video frame into a texture and exposes the command buffer for presentation.

```
@MainActor class ImmersivePreviewRenderer
```

## Overview

`ImmersivePreviewRenderer` provides a high-level interface for rendering immersive video content with support for
stereoscopic rendering, presentation commands, and venue-specific camera models. It manages the rendering pipeline
including geometry setup, texture management, and frame processing.

The renderer supports two rendering modes:

- macOS: Rendering directly to a specified texture with manual camera control via rotation and field of view parameters.
- visionOS: Rendering to `LayerRenderer.Drawable` instances with automatic head tracking and view management.

Create a renderer with a venue descriptor that defines the camera models and rendering geometry:

```swift
let venueDescriptor = try VenueDescriptor(aimeFileURL: aimeURL)
let renderer = ImmersivePreviewRenderer(venueDescriptor: venueDescriptor)
```

On macOS, render frames directly to a texture:

```swift
await renderer.process(
    frame,
    for: .left,
    rotation: currentRotation,
    fieldOfView: 90,
    presentationDescriptor: descriptor,
    renderTexture: drawable.texture
)
```

On visionOS, integrate with CompositorServices for immersive rendering:

```swift
await renderer.process(
    frame,
    presentationDescriptor: descriptor,
    drawable: drawable
)
```

Finally, present and commit command buffer:

```swift
if let commandBuffer = renderer.commandBuffer {
    commandBuffer.present(drawable)
    commandBuffer.commit()
}
```

## Topics

### Initializers

[`init(device: (any MTLDevice)?, venueDescriptor: VenueDescriptor?, depthPixelFormat: MTLPixelFormat?, colorPixelFormat: MTLPixelFormat?)`](/documentation/ImmersiveMediaSupport/ImmersivePreviewRenderer/init(device:venueDescriptor:depthPixelFormat:colorPixelFormat:))

Creates an immersive preview renderer.

### Instance Properties

[`var commandBuffer: (any MTLCommandBuffer)?`](/documentation/ImmersiveMediaSupport/ImmersivePreviewRenderer/commandBuffer)

The command buffer of the render.

[`var venueDescriptor: VenueDescriptor?`](/documentation/ImmersiveMediaSupport/ImmersivePreviewRenderer/venueDescriptor)

The venue descriptor for rendering immersive video frames.

### Instance Methods

[`func process(ImmersiveVideoFrame, for: ImmersivePreviewRenderer.Eye, rotation: Rotation3D, fieldOfView: Float, presentationDescriptor: PresentationDescriptor, renderTexture: any MTLTexture) async`](/documentation/ImmersiveMediaSupport/ImmersivePreviewRenderer/process(_:for:rotation:fieldOfView:presentationDescriptor:renderTexture:))

Performs the rendering of an immersive video frame.

[`func process(ImmersiveVideoFrame, presentationDescriptor: PresentationDescriptor, drawable: LayerRenderer.Drawable) async`](/documentation/ImmersiveMediaSupport/ImmersivePreviewRenderer/process(_:presentationDescriptor:drawable:))

Performs the rendering of an immersive video frame.

### Enumerations

[`enum Eye`](/documentation/ImmersiveMediaSupport/ImmersivePreviewRenderer/Eye)

An enumeration that represents the eye of the user.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

---

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)