pub struct SpotLight {
pub direction: Vec3,
pub color: LinearRgba,
pub intensity: f32,
pub range: f32,
pub inner_cone_angle: f32,
pub outer_cone_angle: f32,
pub shadow_enabled: bool,
pub shadow_bias: f32,
pub shadow_normal_bias: f32,
}Expand description
A spot light source that emits light in a cone from a single point.
Spot lights are like point lights but restricted to a cone of influence. They’re useful for flashlights, stage lights, and car headlights.
§Examples
use khora_core::renderer::light::SpotLight;
use khora_core::math::{Vec3, LinearRgba};
// Create a flashlight
let flashlight = SpotLight {
direction: Vec3::new(0.0, 0.0, -1.0),
color: LinearRgba::WHITE,
intensity: 200.0,
range: 20.0,
inner_cone_angle: 15.0_f32.to_radians(),
outer_cone_angle: 30.0_f32.to_radians(),
shadow_enabled: false,
shadow_bias: 0.01,
shadow_normal_bias: 0.0,
};Fields§
§direction: Vec3The direction the spotlight is pointing (normalized).
color: LinearRgbaThe color of the light in linear RGB space.
intensity: f32The intensity of the light in lumens.
range: f32The maximum range of the light in world units.
inner_cone_angle: f32The angle in radians at which the light begins to fall off.
Within this angle from the center of the cone, the light is at full intensity.
outer_cone_angle: f32The angle in radians at which the light is fully attenuated.
Beyond this angle from the center of the cone, there is no light. The region between inner and outer cone angles has smooth falloff.
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.