MDLLightProbe
A light source described in terms of the variations in color and intensity of its illumination in all directions.
Declaration
class MDLLightProbeOverview
A light probe represents this variation either as a cube map texture or as a set of spherical harmonic coefficients. In addition to describing such light sources, the MDLLightProbe class provides methods for generating light probe textures based on the contents of a scene and for generating spherical harmonic coefficients from a texture.
A light probe consists of two cube map textures, where each texel represents the color and intensity of light in a particular direction from the cube’s center:
The reflectiveTexture cube map, also known as an environment map, contains a rendering of a scene as viewed from the light probe’s position. A renderer can use this texture to create reflections on surfaces with metallic materials.
The irradianceTexture cube map contains samples of the total light arriving at the light probe’s position from every direction. A renderer can use this texture to create diffuse lighting effects. You can derive an irradiance map from an environment map with methods on the MDLTexture class, or when creating a light probe with the init(textureSize:forLocation:lightsToConsider:objectsToConsider:reflectiveCubemap:irradianceCubemap:) method.
Using cube map textures for light-probe-based rendering offers great visual fidelity, but adversely affects performance due to the cost of texture lookups during rendering. In addition, a cube map texture often contains more detail than is necessary for lighting. A set of spherical harmonic coefficients can represent the same information with less detail, and can be used in shader calculations with much less performance cost. To use spherical harmonics, call the generateSphericalHarmonics(fromIrradiance:) method, then access the generated data in the sphericalHarmonicsCoefficients property.