<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "ModelIO",
  "identifier" : "/documentation/ModelIO/MDLPhotometricLight/generateSphericalHarmonics(fromLight:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Model I/O"
    ],
    "preciseIdentifier" : "c:objc(cs)MDLPhotometricLight(im)generateSphericalHarmonicsFromLight:"
  },
  "title" : "generateSphericalHarmonics(fromLight:)"
}
-->

# generateSphericalHarmonics(fromLight:)

Generates spherical harmonics information based on the light’s photometry data.

```
func generateSphericalHarmonics(fromLight sphericalHarmonicsLevel: Int)
```

## Parameters

`sphericalHarmonicsLevel`

The number of levels for which to generate spherical harmonics. Each level of spherical harmonics contains more coefficients, affecting both the layout of the resulting data and the detail of any lighting effects based on it.

## Discussion

Spherical harmonic coefficients describe the distribution of light around a light source with less high-frequency detail than a cube map texture, but they can be used more efficiently in real-time rendering. After calling this method, use the [`sphericalHarmonicsCoefficients`](/documentation/ModelIO/MDLPhotometricLight/sphericalHarmonicsCoefficients) property to access the generated coefficients.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)