<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ModelIO",
  "identifier" : "/documentation/ModelIO/MDLTexture",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Model I/O"
    ],
    "preciseIdentifier" : "c:objc(cs)MDLTexture"
  },
  "title" : "MDLTexture"
}
-->

# MDLTexture

A source of texel data to be used in rendering material surface appearances.

```
class MDLTexture
```

## Overview

You use the [`MDLTexture`](/documentation/ModelIO/MDLTexture) class or one of its subclasses to identify, load, or create texture data, and then associate textures with materials using the [`MDLTextureSampler`](/documentation/ModelIO/MDLTextureSampler) and [`MDLMaterialProperty`](/documentation/ModelIO/MDLMaterialProperty) classes. When you load 3D objects from an asset file (in a format that supports texturing) with the [`MDLAsset`](/documentation/ModelIO/MDLAsset) class, Model I/O automatically creates texture objects and material objects and associates them with the [`MDLSubmesh`](/documentation/ModelIO/MDLSubmesh) objects in the asset.

## Topics

### Loading Textures from a Bundle

[`+  textureNamed:`](/documentation/ModelIO/MDLTexture/init(named:))

Loads the texture with the specified filename from the app’s main bundle.

[`+  textureNamed:bundle:`](/documentation/ModelIO/MDLTexture/init(named:bundle:))

Loads the texture with the specified filename from the specified bundle.

[`+  textureCubeWithImagesNamed:`](/documentation/ModelIO/MDLTexture/init(cubeWithImagesNamed:))

Loads a cube texture from the specified image files in the app’s main bundle.

[`+  textureCubeWithImagesNamed:bundle:`](/documentation/ModelIO/MDLTexture/init(cubeWithImagesNamed:bundle:))

Loads a cube texture from the specified image files in the specified bundle.

### Creating Textures

[`-  initWithData:topLeftOrigin:name:dimensions:rowStride:channelCount:channelEncoding:isCube:`](/documentation/ModelIO/MDLTexture/init(data:topLeftOrigin:name:dimensions:rowStride:channelCount:channelEncoding:isCube:))

Initializes a texture object with the specified image data and properties.

### Exporting Textures

[`-  writeToURL:`](/documentation/ModelIO/MDLTexture/write(to:))

Exports the texture data to an image file at the specified URL.

[`-  writeToURL:type:`](/documentation/ModelIO/MDLTexture/write(to:type:))

Exports the texture data to an image file at the specified URL, of the specified type.

[`-  imageFromTexture`](/documentation/ModelIO/MDLTexture/imageFromTexture())

Exports the texture data as a CoreGraphics image.

### Accessing Texture Data

[`-  texelDataWithTopLeftOrigin`](/documentation/ModelIO/MDLTexture/texelDataWithTopLeftOrigin())

Returns the texture’s image data, organized such that its first pixel represents the top-left corner of the image.

[`-  texelDataWithBottomLeftOrigin`](/documentation/ModelIO/MDLTexture/texelDataWithBottomLeftOrigin())

Returns the texture’s image data, organized such that its first pixel represents the bottom-left corner of the image.

[`-  texelDataWithTopLeftOriginAtMipLevel:create:`](/documentation/ModelIO/MDLTexture/texelDataWithTopLeftOrigin(atMipLevel:create:))

Returns the texture’s image data for the specified mipmap level, organized such that its first pixel represents the top-left corner of the image.

[`-  texelDataWithBottomLeftOriginAtMipLevel:create:`](/documentation/ModelIO/MDLTexture/texelDataWithBottomLeftOrigin(atMipLevel:create:))

Returns the texture’s image data for the specified mipmap level, organized such that its first pixel represents the bottom-left corner of the image.

### Examining Texture Attributes

[`dimensions`](/documentation/ModelIO/MDLTexture/dimensions)

The width and height, in texels, of the texture image.

[`rowStride`](/documentation/ModelIO/MDLTexture/rowStride)

The number of bytes between the first texel in a row of image data and the first texel in the next row.

[`channelCount`](/documentation/ModelIO/MDLTexture/channelCount)

The number of channels per texel.

[`channelEncoding`](/documentation/ModelIO/MDLTexture/channelEncoding)

The data format for each channel value per texel.

[`isCube`](/documentation/ModelIO/MDLTexture/isCube)

A Boolean value that indicates whether the texture is a cube textures.

[`mipLevelCount`](/documentation/ModelIO/MDLTexture/mipLevelCount)

The number of mipmap levels contained in the texture image data.

### Creating Irradiance Textures

[`+  irradianceTextureCubeWithTexture:name:dimensions:`](/documentation/ModelIO/MDLTexture/irradianceTextureCube(with:name:dimensions:))

Generates an irradiance texture from the specified reflectance cube texture.

[`+  irradianceTextureCubeWithTexture:name:dimensions:roughness:`](/documentation/ModelIO/MDLTexture/irradianceTextureCube(with:name:dimensions:roughness:))

Generates an irradiance texture from the specified reflectance cube texture, assuming a surface of the specified roughness.

### Constants

[`MDLTextureChannelEncoding`](/documentation/ModelIO/MDLTextureChannelEncoding)

Options for the data size and type of texel channel values, used by the [`channelEncoding`](/documentation/ModelIO/MDLTexture/channelEncoding) property.

## Relationships

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Conforms To

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

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

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

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

[`MDLNamed`](/documentation/ModelIO/MDLNamed)

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

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

### Inherited By

[`MDLColorSwatchTexture`](/documentation/ModelIO/MDLColorSwatchTexture)

[`MDLCheckerboardTexture`](/documentation/ModelIO/MDLCheckerboardTexture)

[`MDLNoiseTexture`](/documentation/ModelIO/MDLNoiseTexture)

[`MDLURLTexture`](/documentation/ModelIO/MDLURLTexture)

[`MDLSkyCubeTexture`](/documentation/ModelIO/MDLSkyCubeTexture)

[`MDLNormalMapTexture`](/documentation/ModelIO/MDLNormalMapTexture)

---

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)