Skip to main content

he3d_core/
light.rs

1use he3d_math::Vec3;
2
3use crate::Rgb;
4
5/// A directional light: one direction plus color and strength.
6/// 方向光:一个光照方向加上颜色与强度。
7#[derive(Clone, Copy, PartialEq, Debug)]
8pub struct DirectionalLight {
9   /// Direction from a surface toward the light; not a position. The shading term
10   /// is `normal · direction`, so the renderer normalizes this and ignores its
11   /// length.
12   /// 从表面指向光源的方向,不是位置。着色项为 `normal · direction`,因此渲染器会将其
13   /// 归一化,长度被忽略。
14   pub direction: Vec3,
15   /// Light color and strength.
16   /// 光的颜色和强度。
17   pub color: Rgb,
18   /// Base brightness added to every lit surface.
19   /// 添加到每个被照亮表面的基础亮度。
20   pub ambient: f32,
21}
22
23impl Default for DirectionalLight {
24   fn default() -> Self {
25      Self {
26         direction: Vec3::new(0.0, -1.0, 1.0),
27         color: Rgb::WHITE,
28         ambient: 0.15,
29      }
30   }
31}