<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/DirectionalLightComponent",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation25DirectionalLightComponentV"
  },
  "title" : "DirectionalLightComponent"
}
-->

# DirectionalLightComponent

A component that defines a directional light source.

```
struct DirectionalLightComponent
```

## Overview

A directional light shines in the entity’s forward direction `[0, 0, -1]`.

Change the a directional light’s direction with the `Entity/orientation` or
[`look(at:from:upVector:relativeTo:)`](/documentation/RealityKit/HasTransform/look(at:from:upVector:relativeTo:)) method
of the [`Entity`](/documentation/RealityKit/Entity) with a `DirectionalLightComponent`.
The position of the entity does not play a part in the directional light’s effect.

> Tip: Turn on shadows for a directional light by adding the ``doc://com.apple.RealityKit/documentation/RealityKit/DirectionalLightComponent/Shadow`` component
> to an entity that has a `DirectionalLightComponent`.

Use this component with shadows by adding `DirectionalLightComponent`
and [`DirectionalLightComponent.Shadow`](/documentation/RealityKit/DirectionalLightComponent/Shadow) to an entity’s [`components`](/documentation/RealityKit/Entity/components) set.
In this example, the light’s color is red, and the intensity is `10_000`,
which is an approximate lux for ambient daylight:

```swift
let lightEntity = Entity()

let redLightComponent = DirectionalLightComponent(
    color: .red, intensity: 10_000
)
let lightShadowComponent = DirectionalLightComponent.Shadow()
lightEntity.components.set([redLightComponent, lightShadowComponent])
```

The directional light illuminates entities evenly in the direction it derives from the orientation of `lightEntity`.
Here is a visual example of how the above code snippet could illuminates entities in a scene:

|Without a directional light                                                                                                                                                                   |With a directional light                                                                                                                                                                                                                                                 |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
|![A screenshot of a RealityKit scene with a dark gray floor, a light gray cube. There is no obvious lighting in the scene, so the edges of the cube are not clear.](directionallight-cube-off)|![A screenshot of a RealityKit scene with a dark gray floor, a light gray cube, and five small green arrows in a row above the cube. There is a red light uniformly affecting the scene from above, casting a shadow to the right of the cube.](directionallight-cube-on)|

> Note: The green arrows in the above illustration are only a visual representation of the light’s direction.

## Dynamic light capacity

On older hardware, only a limited number of dynamic lights can affect each object.
Devices that support `MTLGPUFamily.apple6` or later lift this limit.

Excessive use of dynamic lights may contribute to user-noticeable frame drops and
can cause the device to heat up in graphically demanding situations. Monitor the
thermal state and reduce the number of lights as a mitigation, if necessary.

Because this behavior varies by device, verify your scene’s lighting on the oldest
hardware you support. You can check for this support at runtime with
`MTLDevice.supportsFamily(.apple6)`.

## Topics

### Creating a directional light

[`init(color: DirectionalLightComponent.Color, intensity: Float)`](/documentation/RealityKit/DirectionalLightComponent/init(color:intensity:))

Creates a directional light with a configuration.

[`init(color: DirectionalLightComponent.Color, intensity: Float, isRealWorldProxy: Bool)`](/documentation/RealityKit/DirectionalLightComponent/init(color:intensity:isRealWorldProxy:)-42x82)

Creates a directional light with a configuration.

[`init(color: DirectionalLightComponent.Color, intensity: Float, isRealWorldProxy: Bool)`](/documentation/RealityKit/DirectionalLightComponent/init(color:intensity:isRealWorldProxy:)-42x82)

Creates a directional light with a configuration.

### Setting the color

[`var color: DirectionalLightComponent.Color`](/documentation/RealityKit/DirectionalLightComponent/color-5ebuh)

A color for the directional light.

[`var color: DirectionalLightComponent.Color`](/documentation/RealityKit/DirectionalLightComponent/color-5ebuh)

A color for the directional light.

### Setting intensity and shadows

[`var intensity: Float`](/documentation/RealityKit/DirectionalLightComponent/intensity)

The intensity of the directional light, measured in lumen per square
meter.

[`var isRealWorldProxy: Bool`](/documentation/RealityKit/DirectionalLightComponent/isRealWorldProxy)

A Boolean that you use to control whether the directional light operates
as a proxy for a real-world light.

### Supporting types

[`typealias Color`](/documentation/RealityKit/DirectionalLightComponent/Color-swift.typealias)

A platform-specific type used to define color for a directional light.

### Assigning render layers

[`var layers: RenderLayer.Set`](/documentation/RealityKit/DirectionalLightComponent/layers)

The layers this light illuminates.

### Structures

[`struct Shadow`](/documentation/RealityKit/DirectionalLightComponent/Shadow)

A directional light component that adds shadows to entities that it illuminates

### Initializers

[`init(color:intensity:isRealWorldProxy:)`](/documentation/RealityKit/DirectionalLightComponent/init(color:intensity:isRealWorldProxy:))

Creates a directional light with a configuration.

### Instance Properties

[`var color: DirectionalLightComponent.Color`](/documentation/RealityKit/DirectionalLightComponent/color-7hs4n)

A color for the directional light.

## Relationships

### Conforms To

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

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

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

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

---

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)