Contents

PointLightComponent

A component that defines a point light source.

Declaration

struct PointLightComponent

Mentioned in

Overview

The strength of a point light depends on a combination of its intensity and attenuationRadius. The default values for these properties make this light comparable to high-power streetlights, or outdoor floodlights.

This table shows a few examples of common scenarios similar to a point light source:

Scenario

Approximate lumens

Attenuation radius

Description

Candle flame

10-15 lumens

~1 meter

Very small light source

Nightlight

20-30 lumens

1-2 meters

Low-level lighting

25W lightbulb

200-300 lumens

2-3 meters

Small room lighting

40W lightbulb

400-500 lumens

3-4 meters

Moderate room lighting

60W lightbulb

700-800 lumens

4-5 meters

General-purpose lighting

100W lightbulb

1,500-1,700 lumens

5-6 meters

Bright room lighting

LED flashlight

300-600 lumens

50-70 meters

Long distance illumination

Car headlights (each, low-beam)

700-1,200 lumens

100-150 meters

Illuminates the road ahead

LED streetlight

8,000-10,000 lumens

20-30 meters

Illuminates large outdoor areas

Stadium lighting

~100,000 lumens

100-200 meters

Lights-up large outdoor areas

Use this component by applying it to an entity’s components set. In this example, the light’s color is red:

let lightEntity = Entity()

let redLightComponent = PointLightComponent(color: .red)
lightEntity.components.set(redLightComponent)

The point light illuminates entities based on its distance from them. Here is a visual example of how a red PointLightComponent illuminates elements based on distance:

[Image]

[Image]

[Image]

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. Both the number of lights and each light’s coverage affect performance, so use properties like attenuationRadius to keep a light’s influence no larger than your scene needs. Monitor the thermal state and reduce usage 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 point light component

Configuring the light

Supporting types

Assigning render layers

Lighting the surroundings

Initializers

Instance Properties