<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/TextureResource/texture3D(slices:named:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation15TextureResourceC9texture3D6slices5named7optionsACSaySo10CGImageRefaG_SSSgAC13CreateOptionsVtYaKFZ::OverloadGroup"
  },
  "title" : "texture3D(slices:named:options:)"
}
-->

# texture3D(slices:named:options:)

Asynchronously creates a 3D texture by generating it from images.

```
@MainActor @preconcurrency static func texture3D(slices: [CGImage], named resourceName: String? = nil, options: TextureResource.CreateOptions) async throws -> TextureResource
```

## Parameters

`slices`

The source images, one per depth index.
All images need to be square, and of equal size and format.

`resourceName`

A unique name for syncing the texture resource across the network.
The name is empty if you don’t include one.

`options`

A configuration for generating the texture.

## Discussion

RealityKit creates a <doc://com.apple.documentation/documentation/Metal/MTLTextureType/type3D>
texture with `depth == slices.count` from an array of images.

You can assign the resulting texture to a material you create in Reality Composer Pro that requires a 3D texture.

```swift
// Create a 3D texture from image slices.
let texture3D = try await TextureResource.texture3D(
    slices: [image0, image1, image2, image3],
    options: TextureResource.CreateOptions(semantic: .color))

// Assign the 3D texture to a compatible shader graph material parameter.
var material = try await ShaderGraphMaterial(
    named: "/Root/Alien/MaterialWith3DTexture", from: url)

try material.setParameter(
name: "input3DTexture",
value: .textureResource(texture3D))
```

---

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)