---
title: "texture3D(slices:named:options:)"
framework: realitykit
role: symbol
role_heading: Type Method
path: "realitykit/textureresource/texture3d(slices:named:options:)"
---

# texture3D(slices:named:options:)

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

## Declaration

```swift
@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

Discussion RealityKit creates a 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. // 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))
