pub struct DirectionalLight {
pub direction: Vec3,
pub color: LinearRgba,
pub intensity: f32,
pub shadow_enabled: bool,
pub shadow_bias: f32,
pub shadow_normal_bias: f32,
}Expand description
A directional light source that illuminates from a uniform direction.
Directional lights simulate infinitely distant light sources like the sun. They have no position, only a direction, and cast parallel rays with no falloff.
§Examples
use khora_core::renderer::light::DirectionalLight;
use khora_core::math::{Vec3, LinearRgba};
// Create a warm sunlight
let sun = DirectionalLight {
direction: Vec3::new(-0.5, -1.0, -0.3).normalize(),
color: LinearRgba::new(1.0, 0.95, 0.8, 1.0),
intensity: 1.0,
shadow_enabled: true,
shadow_bias: 0.005,
shadow_normal_bias: 0.02,
};Fields§
§direction: Vec3The direction the light is pointing (normalized).
This vector points from the light source towards the scene.
For a sun at noon, this would be (0, -1, 0).
color: LinearRgbaThe color of the light in linear RGB space.
intensity: f32The intensity multiplier for the light.
A value of 1.0 represents standard intensity. Higher values create brighter lights, useful for HDR rendering.
shadow_enabled: boolWhether this light casts shadows.
shadow_bias: f32Constant bias to apply to depth values to prevent shadow acne.
shadow_normal_bias: f32Normal-based bias to apply to prevent shadow acne on sloped surfaces.
Trait Implementations§
Source§impl<'__de, __Context> BorrowDecode<'__de, __Context> for DirectionalLight
impl<'__de, __Context> BorrowDecode<'__de, __Context> for DirectionalLight
Source§fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>(
decoder: &mut __D,
) -> Result<Self, DecodeError>
fn borrow_decode<__D: BorrowDecoder<'__de, Context = __Context>>( decoder: &mut __D, ) -> Result<Self, DecodeError>
Attempt to decode this type with the given BorrowDecode.
Source§impl Clone for DirectionalLight
impl Clone for DirectionalLight
Source§fn clone(&self) -> DirectionalLight
fn clone(&self) -> DirectionalLight
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DirectionalLight
impl Debug for DirectionalLight
Source§impl<__Context> Decode<__Context> for DirectionalLight
impl<__Context> Decode<__Context> for DirectionalLight
Source§impl Default for DirectionalLight
impl Default for DirectionalLight
Source§impl<'de> Deserialize<'de> for DirectionalLight
impl<'de> Deserialize<'de> for DirectionalLight
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Encode for DirectionalLight
impl Encode for DirectionalLight
Source§impl PartialEq for DirectionalLight
impl PartialEq for DirectionalLight
Source§fn eq(&self, other: &DirectionalLight) -> bool
fn eq(&self, other: &DirectionalLight) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for DirectionalLight
impl Serialize for DirectionalLight
impl Copy for DirectionalLight
impl StructuralPartialEq for DirectionalLight
Auto Trait Implementations§
impl Freeze for DirectionalLight
impl RefUnwindSafe for DirectionalLight
impl Send for DirectionalLight
impl Sync for DirectionalLight
impl Unpin for DirectionalLight
impl UnsafeUnpin for DirectionalLight
impl UnwindSafe for DirectionalLight
Blanket Implementations§
Source§impl<T> AppLifecycle for Twhere
T: ?Sized,
impl<T> AppLifecycle for Twhere
T: ?Sized,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more