Class

MDLTexture

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

Declaration

@interface MDLTexture : NSObject

Overview

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

Topics

Loading Textures from a Bundle

+ textureNamed:

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

+ textureNamed:bundle:

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

+ textureCubeWithImagesNamed:

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

+ textureCubeWithImagesNamed:bundle:

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

Creating Textures

- initWithData:topLeftOrigin:name:dimensions:rowStride:channelCount:channelEncoding:isCube:

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

Exporting Textures

- writeToURL:

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

- writeToURL:type:

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

- imageFromTexture

Exports the texture data as a CoreGraphics image.

Accessing Texture Data

- texelDataWithTopLeftOrigin

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

- texelDataWithBottomLeftOrigin

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

- texelDataWithTopLeftOriginAtMipLevel: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:

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

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

rowStride

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

channelCount

The number of channels per texel.

channelEncoding

The data format for each channel value per texel.

isCube

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

mipLevelCount

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

Creating Irradiance Textures

+ irradianceTextureCubeWithTexture:name:dimensions:

Generates an irradiance texture from the specified reflectance cube texture.

+ irradianceTextureCubeWithTexture:name:dimensions:roughness:

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

Constants

MDLTextureChannelEncoding

Options for the data size and type of texel channel values, used by the channelEncoding property.

Instance Properties

Relationships

Inherits From

Conforms To

See Also

Textures

MDLCheckerboardTexture

A generator of texel data that creates a checkerboard pattern with two specified colors.

MDLColorSwatchTexture

A generator of texel data that creates a gradient between two specified colors.

MDLNoiseTexture

A generator of texel data that creates a field of random noise.

MDLNormalMapTexture

A generator of texel data that computes a normal map from a supplied texture.

MDLSkyCubeTexture

A generator of texel data that creates cube textures using a physically realistic simulation of the sunlit sky.

MDLURLTexture

A lightweight reference to a URL from which to load texture data.

MDLTextureFilter

A description of filtering modes for a renderer to use when sampling from a texture.

MDLTextureSampler

An object that pairs a source of texture data with sampling parameters to be used in rendering the texture.