pub struct PointLight {
pub color: LinearRgba,
pub intensity: f32,
pub range: f32,
pub shadow_enabled: bool,
pub shadow_bias: f32,
pub shadow_normal_bias: f32,
}Expand description
A point light source that emits light in all directions from a single point.
Point lights simulate local light sources like light bulbs or candles. They have a position (provided by the entity’s transform) and attenuate with distance according to the inverse-square law.
§Examples
use khora_core::renderer::light::PointLight;
use khora_core::math::LinearRgba;
// Create a warm indoor light
let lamp = PointLight {
color: LinearRgba::new(1.0, 0.9, 0.7, 1.0),
intensity: 100.0,
range: 10.0,
shadow_enabled: false,
shadow_bias: 0.01,
shadow_normal_bias: 0.0,
};Fields§
§color: LinearRgbaThe color of the light in linear RGB space.
intensity: f32The intensity of the light in lumens.
Higher values create brighter lights. This is used in conjunction with the physically-based attenuation formula.
range: f32The maximum range of the light in world units.
Beyond this distance, the light has no effect. This is used for performance optimization to cull lights that won’t contribute to a fragment’s lighting.
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 PointLight
impl<'__de, __Context> BorrowDecode<'__de, __Context> for PointLight
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>
Source§impl Clone for PointLight
impl Clone for PointLight
Source§fn clone(&self) -> PointLight
fn clone(&self) -> PointLight
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PointLight
impl Debug for PointLight
Source§impl<__Context> Decode<__Context> for PointLight
impl<__Context> Decode<__Context> for PointLight
Source§impl Default for PointLight
impl Default for PointLight
Source§impl<'de> Deserialize<'de> for PointLight
impl<'de> Deserialize<'de> for PointLight
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>,
Source§impl Encode for PointLight
impl Encode for PointLight
Source§impl PartialEq for PointLight
impl PartialEq for PointLight
Source§fn eq(&self, other: &PointLight) -> bool
fn eq(&self, other: &PointLight) -> bool
self and other values to be equal, and is used by ==.