Class

MDLMaterial

A collection of material properties that together describe the intended surface appearance for rendering a 3D object.

Declaration

class MDLMaterial : NSObject

Overview

Each material property (a MDLMaterialProperty object) provides one specific aspect of appearance, such as opacity, shininess, or surface detail. Use the material property of a MDLSubmesh object to associate a material with a 3D object for rendering or to find the material assigned to an object loaded from an asset file.

Sets of certain material properties called scattering functions determine the material’s response to lighting. You can manage these properties together using a material’s scatteringFunction property. Creating a material with the inherited init() initializer is equivalent to using the init(name:scatteringFunction:) with a MDLScatteringFunction object whose properties all have default values.

Topics

Creating a Material

init(scnMaterial: SCNMaterial)

Creates a material object from the specified SceneKit material object.

Determining a Material’s Response to Lighting

var scatteringFunction: MDLScatteringFunction

The collection of material properties that define the material’s response to light.

Working with Individual Material Properties

func propertyNamed(String) -> MDLMaterialProperty?

Returns the material property with the specified name.

func property(with: MDLMaterialSemantic) -> MDLMaterialProperty?

Returns the material property for the specified material semantic.

func setProperty(MDLMaterialProperty)

Adds a new material property to or replaces an existing material property in the material.

func remove(MDLMaterialProperty)

Removes the specified material property from the material.

func removeAllProperties()

Removes all material properties from the material.

Sharing Material Properties

var base: MDLMaterial?

Another material object from which this material’s properties are derived.

Accessing Material Properties with Subscript Syntax

subscript(String) -> MDLMaterialProperty?

Returns the material property with the specified name, for use with subscript syntax.

subscript(Int) -> MDLMaterialProperty?

Returns the material property at the specified index in the material, for use with subscript syntax.

var count: Int

The number of material properties in the material.

Naming a Material

var name: String

A descriptive name for the material.

See Also

Materials

class MDLMaterialProperty

A definition for one specific aspect of the rendering parameters for a material.

class MDLScatteringFunction

A set of material properties that describes a basic shading model for materials, and the superclass for more complex shading models.

class MDLPhysicallyPlausibleScatteringFunction

A set of material properties that describes a physically realistic shading model for materials.