pub struct LightManager {
pub point_lights: Vec<PointLight>,
pub spot_lights: Vec<SpotLight>,
pub directional: Option<DirectionalLight>,
pub ambient: AmbientLight,
pub probes: Vec<LightProbe>,
pub ssao: SsaoConfig,
pub volumetric: VolumetricConfig,
pub emissive: EmissiveAccumulator,
pub culler: Option<LightCuller>,
/* private fields */
}Expand description
Central light registry. Owns all lights and manages culling.
Fields§
§point_lights: Vec<PointLight>§spot_lights: Vec<SpotLight>§directional: Option<DirectionalLight>§ambient: AmbientLight§probes: Vec<LightProbe>§ssao: SsaoConfig§volumetric: VolumetricConfig§emissive: EmissiveAccumulator§culler: Option<LightCuller>Implementations§
Source§impl LightManager
impl LightManager
pub fn new() -> Self
pub fn add_point_light(&mut self, light: PointLight) -> LightId
pub fn add_spot_light(&mut self, light: SpotLight) -> LightId
pub fn set_directional(&mut self, light: DirectionalLight) -> LightId
pub fn add_probe(&mut self, probe: LightProbe) -> LightId
pub fn remove(&mut self, id: LightId)
pub fn get_point_light_mut(&mut self, id: LightId) -> Option<&mut PointLight>
pub fn get_spot_light_mut(&mut self, id: LightId) -> Option<&mut SpotLight>
Sourcepub fn init_culler(&mut self, screen_w: u32, screen_h: u32)
pub fn init_culler(&mut self, screen_w: u32, screen_h: u32)
Set up the tile culler for a given screen size.
Sourcepub fn flush_emissive(&mut self, intensity_scale: f32)
pub fn flush_emissive(&mut self, intensity_scale: f32)
Update emissive auto-lights from this frame’s accumulator.
Sourcepub fn cull(&mut self, view_proj: Mat4)
pub fn cull(&mut self, view_proj: Mat4)
Run light culling. Call once per frame after updating light positions.
Sourcepub fn light_count(&self) -> usize
pub fn light_count(&self) -> usize
Total active light count.
Sourcepub fn evaluate_cpu(&self, p: Vec3, n: Vec3) -> Vec3
pub fn evaluate_cpu(&self, p: Vec3, n: Vec3) -> Vec3
Evaluate the total light contribution at a world-space point with normal. Used for CPU-side lighting (debug, probes, etc.).
Sourcepub fn remove_by_tag(&mut self, tag: &str)
pub fn remove_by_tag(&mut self, tag: &str)
Remove all lights with a given tag.
Sourcepub fn set_enabled_by_tag(&mut self, tag: &str, enabled: bool)
pub fn set_enabled_by_tag(&mut self, tag: &str, enabled: bool)
Enable/disable all lights with a given tag.
Sourcepub fn scale_intensity(&mut self, factor: f32)
pub fn scale_intensity(&mut self, factor: f32)
Scale the intensity of all lights by a factor (e.g., day/night cycle).
Source§impl LightManager
impl LightManager
Sourcepub fn preset_daylight() -> Self
pub fn preset_daylight() -> Self
Bright daylight setup: sun + sky ambient.
Sourcepub fn preset_dungeon() -> Self
pub fn preset_dungeon() -> Self
Low ambient dungeon lighting.
Sourcepub fn preset_void() -> Self
pub fn preset_void() -> Self
Void / deep space: only emissive sources, no ambient.
Sourcepub fn preset_combat_arena(center: Vec3) -> Self
pub fn preset_combat_arena(center: Vec3) -> Self
Combat arena: red-tinted overhead fill + rim lights.
Sourcepub fn preset_interior(center: Vec3) -> Self
pub fn preset_interior(center: Vec3) -> Self
Warm interior room lighting.
Sourcepub fn preset_moonlight() -> Self
pub fn preset_moonlight() -> Self
Moonlit outdoor scene.
Sourcepub fn preset_neon(center: Vec3) -> Self
pub fn preset_neon(center: Vec3) -> Self
Neon-lit cyberpunk street scene.
Sourcepub fn preset_cavern() -> Self
pub fn preset_cavern() -> Self
Underground cavern with bioluminescent blue ambient.
Source§impl LightManager
impl LightManager
Sourcepub fn update_animated(
&mut self,
_animated_points: &mut [AnimatedPointLight],
_animated_spots: &mut [AnimatedSpotLight],
time: f32,
dt: f32,
)
pub fn update_animated( &mut self, _animated_points: &mut [AnimatedPointLight], _animated_spots: &mut [AnimatedSpotLight], time: f32, dt: f32, )
Update all animated lights. Call once per frame.
Sourcepub fn generate_glsl_uniforms(&self) -> String
pub fn generate_glsl_uniforms(&self) -> String
Generate GLSL uniform data for the light manager (for shader injection).
Sourcepub fn shadow_caster_count(&self) -> usize
pub fn shadow_caster_count(&self) -> usize
Count shadow-casting lights.
Sourcepub fn serialize_compact(&self) -> Vec<u8> ⓘ
pub fn serialize_compact(&self) -> Vec<u8> ⓘ
Serialize all lights to a compact binary format.
Sourcepub fn add_fluorescent(&mut self, position: Vec3) -> LightId
pub fn add_fluorescent(&mut self, position: Vec3) -> LightId
Add a cold fluorescent tube.
Sourcepub fn add_candle(&mut self, position: Vec3) -> LightId
pub fn add_candle(&mut self, position: Vec3) -> LightId
Add a candle.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LightManager
impl RefUnwindSafe for LightManager
impl Send for LightManager
impl Sync for LightManager
impl Unpin for LightManager
impl UnsafeUnpin for LightManager
impl UnwindSafe for LightManager
Blanket Implementations§
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.