A container for the color or texture of one of a material’s visual properties.
Language
- Swift
- Objective-C
SDKs
- iOS 8.0+
- macOS 10.8+
- tvOS 8.0+
- watchOS 2.0+
Overview
A material has several visual properties that together determine its appearance under lighting and shading. SceneKit renders each pixel in the scene by combining the information from material properties with the locations, intensities, and colors of lights.
A material property’s contents can be either a color, which provides a uniform effect across the surface of a material, or a texture, which SceneKit maps across the surface of a material using texture coordinates provided by the geometry object the material is attached to. A texture, in turn, can come from any of several sources:
An image object, or a path or URL to an image file
A specially formatted image or array of six images to be used as a cube map
A Core Animation layer or layer hierarchy, which itself may contain animated content
A SpriteKit texture providing a static image, or an entire SpriteKit scene rendering animated 2D content.
SceneKit uses the material property’s contents object in different ways for each visual property of a material. For example:
When you provide a color for the
diffuseproperty, it determines the material’s base color—geometries using the material appear shaded in gradations of this color when illuminated by white light. If you instead provide an image, SceneKit maps the image across the geometry’s surface instead of shading with a uniform base color.When you provide a color for the
specularproperty, it affects the color of light reflected directly toward the viewer from the surface of a geometry using the material. If you instead provide a grayscale image, it determines the tendency of the material to reflect light directly toward the viewer—lighter pixels in the image make those areas of the material appear more shiny, and darker pixels make the material appear more matte.The
normalproperty specifies the orientation of a surface at each point. Materials are uniformly smooth by default, so specifying a color for this property has no useful effect. Instead, you can specify an image for this property that describes the contours of the surface. SceneKit uses this image (called a normal map) in lighting, creating the illusion of a complex, bumpy surface without increasing the complexity of the geometry.
For more details on each visual property and the ways their contents affect a material’s appearance, see SCNMaterial.
SceneKit also uses SCNMaterialProperty objects elsewhere:
To provide content to be rendered behind a scene, in the
backgroundproperty of anSCNSceneobject,To affect the color and shape of illumination from a light source, in the
goboproperty of anSCNLightobject.To bind texture samplers to custom GLSL shader source code snippets, in classes conforming to the
SCNShadableprotocol.