bevy_light/rect_light.rs
1use bevy_camera::visibility::{Visibility, VisibilityClass};
2use bevy_color::Color;
3use bevy_ecs::prelude::*;
4use bevy_reflect::prelude::*;
5use bevy_transform::components::Transform;
6
7use crate::light_consts;
8
9/// A rectangular area light.
10///
11/// The rectangle lies in the XY plane of the entity's local coordinate frame
12/// and faces the local -Z direction.
13///
14/// Shadow maps are currently unsupported, objects illuminated by a
15/// ``RectLight`` will not cast shadows.
16///
17/// Note: Requires the `area_light_luts` cargo feature.
18#[derive(Component, Debug, Clone, Copy, Reflect)]
19#[reflect(Component, Default, Debug, Clone)]
20#[require(Transform, Visibility, VisibilityClass)]
21pub struct RectLight {
22 /// The color of the light.
23 ///
24 /// By default, this is white.
25 pub color: Color,
26
27 /// Luminous power in lumens, representing the amount of light emitted by this source in all directions.
28 pub intensity: f32,
29
30 /// Cut-off for the light's area-of-effect. Fragments outside this range will not be affected by
31 /// this light at all, so it's important to tune this together with `intensity` to prevent hard
32 /// lighting cut-offs.
33 pub range: f32,
34
35 /// Width of the light rectangle (along local X).
36 pub width: f32,
37
38 /// Height of the light rectangle (along local Y).
39 pub height: f32,
40}
41
42impl Default for RectLight {
43 fn default() -> Self {
44 RectLight {
45 color: Color::WHITE,
46 intensity: light_consts::lumens::VERY_LARGE_CINEMA_LIGHT,
47 width: 1.0,
48 height: 1.0,
49 range: 20.0,
50 }
51 }
52}