DirectionalLight
DirectionalLight
- color : bevy_color::color::Color
- illuminance : f32
- shadows_enabled : bool
- shadow_depth_bias : f32
- shadow_normal_bias : f32
Description
A Directional light.
Directional lights don't exist in reality but they are a good approximation for light sources VERY far away, like the sun or the moon.
The light shines along the forward direction of the entity's transform. With a default transform this would be along the negative-Z axis.
Valid values for
illuminance
are:
Illuminance (lux) Surfaces illuminated by 0.0001 Moonless, overcast night sky (starlight) 0.002 Moonless clear night sky with airglow 0.05–0.3 Full moon on a clear night 3.4 Dark limit of civil twilight under a clear sky 20–50 Public areas with dark surroundings 50 Family living room lights 80 Office building hallway/toilet lighting 100 Very dark overcast day 150 Train station platforms 320–500 Office lighting 400 Sunrise or sunset on a clear day. 1000 Overcast day; typical TV studio lighting 10,000–25,000 Full daylight (not direct sun) 32,000–100,000 Direct sunlight Source: Wikipedia
Shadows
To enable shadows, set the
shadows_enabled
property totrue
.Shadows are produced via cascaded shadow maps.
To modify the cascade setup, such as the number of cascades or the maximum shadow distance, change the [
CascadeShadowConfig
] component of the entity with the [DirectionalLight
].To control the resolution of the shadow maps, use the [
DirectionalLightShadowMap
] resource:# use bevy_app::prelude::*; # use bevy_pbr::DirectionalLightShadowMap; App::new() .insert_resource(DirectionalLightShadowMap { size: 2048 });