Class

SCNMaterial

A set of shading attributes that define the appearance of a geometry's surface when rendered.

Declaration

@interface SCNMaterial : NSObject

Overview

When you create a material, you define a collection of visual attributes and their options, which you can then reuse for multiple geometries in a scene.

A material has several visual properties, each of which defines a different part of SceneKit’s lighting and shading process. Each visual property is an instance of the SCNMaterialProperty class that provides a solid color, texture, or other 2D content for that aspect of SceneKit’s rendering. The material’s lightingModelName property then determines the formula SceneKit uses to combine the visual properties with the lights in the scene to produce the final color for each pixel in the rendered scene. For more details on the rendering process, see SCNLightingModel.

You attach one or more materials to an instance of the SCNGeometry class using its firstMaterial or materials property. Multiple geometries can reference the same material. In this case, changing the attributes of the material changes the appearance of every geometry that uses it.

Topics

Creating a Material

material

Creates a new material object.

materialWithMDLMaterial:

Creates a material from the specified Model I/O material object.

name

A name associated with the material.

Choosing a Shading Model

lightingModelName

The lighting formula that SceneKit uses to render the material.

SCNLightingModel

Constants specifying the lighting and shading algorithm to use for rendering a material.

Visual Properties for Physically Based Shading

diffuse

An object that manages the material’s diffuse response to lighting.

metalness

An object that provides color values to determine how metallic the material’s surface appears.

roughness

An object that provides color values to determine the apparent smoothness of the surface.

Visual Properties for Special Effects

normal

An object that defines the nominal orientation of the surface at each point for use in lighting.

emission

An object that defines the color emitted by each point on a surface.

selfIllumination

An object that provides color values representing the global illumination of the surface.

ambientOcclusion

An object that provides color values to be multiplied with the ambient light affecting the material.

Visual Properties for Basic Shading

diffuse

An object that manages the material’s diffuse response to lighting.

ambient

An object that manages the material’s response to ambient lighting.

specular

An object that manages the material’s specular response to lighting.

reflective

An object that defines the reflected color for each point on a surface.

multiply

An object that provides color values that are multiplied with pixels in a material after all other shading is complete.

transparent

An object that determines the opacity of each point in a material.

shininess

The sharpness of specular highlights. Animatable.

fresnelExponent

A factor affecting the material’s reflectivity. Animatable.

locksAmbientWithDiffuse

A Boolean value that determines whether the material responds identically to both ambient and diffuse lighting. Animatable.

Managing Opacity and Blending

transparency

The uniform transparency of the material. Animatable.

transparencyMode

The mode SceneKit uses to calculate transparency for the material.

SCNTransparencyMode

The modes SceneKit uses to calculate the opacity of pixels rendered with a material, used by the transparencyMode property.

blendMode

The mode that determines how pixel colors rendered using this material blend with other pixel colors in the rendering target.

SCNBlendMode

Modes that describe how SceneKit blends source colors rendered using a material with destination colors already in a rendering target, used by the blendMode property.

Customizing Rendered Appearance

litPerPixel

A Boolean value that determines whether SceneKit performs lighting calculations per vertex or per pixel. Animatable.

doubleSided

A Boolean value that determines whether SceneKit should render both front and back faces of a surface. Animatable.

cullMode

The mode determining which faces of a surface SceneKit renders. Animatable.

SCNCullMode

The modes SceneKit uses to determine which polygons to render in a surface, used by the cullMode property.

Managing Render Targets

writesToDepthBuffer

A Boolean value that determines whether SceneKit produces depth information when rendering the material.

readsFromDepthBuffer

A Boolean value that determines whether SceneKit uses depth information when rendering the material.

Relationships

Inherits From

See Also

Lighting, Cameras, and Shading

SCNLight

A light source that can be attached to a node to illuminate the scene.

SCNCamera

A set of camera attributes that can be attached to a node to provide a point of view for displaying the scene.

SCNMaterialProperty

A container for the color or texture of one of a material’s visual properties.