<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/LightmapResource",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation16LightmapResourceC"
  },
  "title" : "LightmapResource"
}
-->

# LightmapResource

A resource containing references to lightmap texture atlases
and descriptions of how parts of the atlases map to meshes in
the scene.

```
final class LightmapResource
```

## Overview

At a high level, [`LightmapResource`](/documentation/RealityKit/LightmapResource) comprises two parts: a set of layered textures containing lightmap data,
and a set of EntityLightmapDescriptors specifying atlas packing.
Both parts (the lightmap data and atlas packing) are expected to be generated by an offline process.
LightmapResource is only intended for storing and retrieving them.
Importantly, [`LightmapResource`](/documentation/RealityKit/LightmapResource) does not store references to runtime Entities.
The correspondence between runtime Entities and their matching EntityLightmapDescriptors is
established by [`LightmapComponent`](/documentation/RealityKit/LightmapComponent).

## Topics

### Structures

[`struct AmbientOcclusionBakeDescriptor`](/documentation/RealityKit/LightmapResource/AmbientOcclusionBakeDescriptor)

Parameters for the ambient occlusion bake type.

[`struct AtlasReference`](/documentation/RealityKit/LightmapResource/AtlasReference)

Specifies an area in a lightmap atlas
to fetch data from.

[`struct EntityLightmapDescriptor`](/documentation/RealityKit/LightmapResource/EntityLightmapDescriptor)

Specifies a MeshPartLightmapDescriptor for each part of the entity’s model.

[`struct FinalShadedColorBakeDescriptor`](/documentation/RealityKit/LightmapResource/FinalShadedColorBakeDescriptor)

Parameters for the final shaded color bake type.

[`struct IndirectDiffuseIrradianceBakeDescriptor`](/documentation/RealityKit/LightmapResource/IndirectDiffuseIrradianceBakeDescriptor)

Parameters for the indirect diffuse irradiance bake type.

[`struct MeshPartLightmapDescriptor`](/documentation/RealityKit/LightmapResource/MeshPartLightmapDescriptor)

Specifies bake descriptors for each instance of the given mesh part.

### Initializers

[`convenience init(atlasTextures: [TextureResource], perEntityData: [LightmapResource.EntityLightmapDescriptor]) throws`](/documentation/RealityKit/LightmapResource/init(atlasTextures:perEntityData:))

Initializes the resource with the given atlases and entity descriptors.
The resources within `atlasTextures` must be 2D texture arrays.
Textures containing data for ambient occlusion should be single-channel textures.
Textures containing data for beauty bakes should contain RGBA color.
Textures for diffuse irradiance should contain RGBA data. There should be 3 slices per
atlas page.
Lightmap textures use the Metal convention, where UV (0,0) corresponds to the top-left corner of
the image while UV (1,1) corresponds to the bottom-right.
Assuming a = sqrt(2), b = sqrt(3), c = sqrt(6), and N0 = (1/c, 1/a, 1/b), N1=(-1/c, -1/a, 1/b), N2 = (a/b, 0, 1/b),
the first, second and third slices should contain lighting as if the surface normal was respectively N0, N1 and N2 in tangent space.

[`convenience init(perEntityData: [LightmapResource.EntityLightmapDescriptor]) throws`](/documentation/RealityKit/LightmapResource/init(perEntityData:))

Initializes the resource with the given entity descriptors, but does not specify any atlas textures.
Skips validation of atlas texture indices and slices within bake descriptors.
This is helpful for providing a SurfaceExtractor with information about how entities are laid out in the lightmap without needing to provide any texture data along with it.

### Instance Properties

[`var bakeTypes: [LightmapResource.BakeType]`](/documentation/RealityKit/LightmapResource/bakeTypes)

All bake types used by entities in this lightmap.

[`var entityCount: Int`](/documentation/RealityKit/LightmapResource/entityCount)

Total number of entities in this lightmap.

### Enumerations

[`enum BakeDescriptor`](/documentation/RealityKit/LightmapResource/BakeDescriptor)

Specifies parameters necessary to fetch a particular
type of light map data for a given instance of a given
mesh part.

[`enum BakeType`](/documentation/RealityKit/LightmapResource/BakeType)

Specifies the type of data contained within a lightmap.

## See Also

[`struct LightmapComponent`](/documentation/RealityKit/LightmapComponent)

Describes how a lightmap is applied to parts of the scene.

## Relationships

### Conforms To

[`Sendable`](/documentation/Swift/Sendable)

[`Resource`](/documentation/RealityKit/Resource)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

---

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)