How do I use directional lights?
Asked on 07/29/2024
1 search
To use directional lights in RealityKit, you can follow the guidance provided in the session "Discover RealityKit APIs for iOS, macOS and visionOS" from WWDC 2024. Here are the key points:
-
Types of Lights: RealityKit offers three types of lights: spotlight, directional light, and point light. A directional light illuminates all objects in a scene uniformly, similar to sunlight.
-
Customization: You can customize the color and intensity of directional lights. Both spotlights and directional lights can cast shadows.
-
Implementation: You can add lights and shadows either through Swift API in code or through Reality Composer Pro, which provides a UI for tuning lighting behavior.
-
Example in Swift:
- Create a new light entity.
- Define the light's transform in code.
- Attach the directional light to the entity.
- Configure the light's properties such as color and intensity.
- Optionally, add a shadow component if you want the light to cast shadows.
For a detailed walkthrough on how to add and configure lights in RealityKit, you can refer to the session Discover RealityKit APIs for iOS, macOS and visionOS (17:07).
Relevant Sessions
- Discover RealityKit APIs for iOS, macOS and visionOS
- Optimize your 3D assets for spatial computing
- Create custom environments for your immersive apps in visionOS
These sessions provide comprehensive insights into lighting, including the use of directional lights, image-based lighting, and optimizing lighting for immersive environments.

Optimize your 3D assets for spatial computing
Dive into an end-to-end workflow for optimized 3D asset creation. Discover best practices for optimizing meshes, materials, and textures in your digital content creation tool. Learn how to harness shader graph, baking, and material instances to enhance your 3D scene while optimizing performance. Take advantage of native tools to work more effectively with your assets and improve your app’s performance.

Enhance your spatial computing app with RealityKit audio
Elevate your spatial computing experience using RealityKit audio. Discover how spatial audio can make your 3D immersive experiences come to life. From ambient audio, reverb, to real-time procedural audio that can add character to your 3D content, learn how RealityKit audio APIs can help make your app more engaging.

Create custom environments for your immersive apps in visionOS
Discover how to create visually rich and performant customized app environments for Apple Vision Pro. Learn design guidelines, get expert recommendations, and explore techniques you can use in any digital content creation tool to begin building your immersive environment.