Skip to main content

LightManager

Struct LightManager 

Source
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

Source

pub fn new() -> Self

Source

pub fn add_point_light(&mut self, light: PointLight) -> LightId

Source

pub fn add_spot_light(&mut self, light: SpotLight) -> LightId

Source

pub fn set_directional(&mut self, light: DirectionalLight) -> LightId

Source

pub fn add_probe(&mut self, probe: LightProbe) -> LightId

Source

pub fn remove(&mut self, id: LightId)

Source

pub fn get_point_light_mut(&mut self, id: LightId) -> Option<&mut PointLight>

Source

pub fn get_spot_light_mut(&mut self, id: LightId) -> Option<&mut SpotLight>

Source

pub fn init_culler(&mut self, screen_w: u32, screen_h: u32)

Set up the tile culler for a given screen size.

Source

pub fn flush_emissive(&mut self, intensity_scale: f32)

Update emissive auto-lights from this frame’s accumulator.

Source

pub fn cull(&mut self, view_proj: Mat4)

Run light culling. Call once per frame after updating light positions.

Source

pub fn light_count(&self) -> usize

Total active light count.

Source

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.).

Source

pub fn remove_by_tag(&mut self, tag: &str)

Remove all lights with a given tag.

Source

pub fn set_enabled_by_tag(&mut self, tag: &str, enabled: bool)

Enable/disable all lights with a given tag.

Source

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

Source

pub fn preset_daylight() -> Self

Bright daylight setup: sun + sky ambient.

Source

pub fn preset_dungeon() -> Self

Low ambient dungeon lighting.

Source

pub fn preset_void() -> Self

Void / deep space: only emissive sources, no ambient.

Source

pub fn preset_combat_arena(center: Vec3) -> Self

Combat arena: red-tinted overhead fill + rim lights.

Source

pub fn preset_interior(center: Vec3) -> Self

Warm interior room lighting.

Source

pub fn preset_moonlight() -> Self

Moonlit outdoor scene.

Source

pub fn preset_neon(center: Vec3) -> Self

Neon-lit cyberpunk street scene.

Source

pub fn preset_cavern() -> Self

Underground cavern with bioluminescent blue ambient.

Source§

impl LightManager

Source

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.

Source

pub fn generate_glsl_uniforms(&self) -> String

Generate GLSL uniform data for the light manager (for shader injection).

Source

pub fn shadow_caster_count(&self) -> usize

Count shadow-casting lights.

Source

pub fn serialize_compact(&self) -> Vec<u8>

Serialize all lights to a compact binary format.

Source

pub fn add_torch(&mut self, position: Vec3) -> LightId

Add a flickering torch light.

Source

pub fn add_fluorescent(&mut self, position: Vec3) -> LightId

Add a cold fluorescent tube.

Source

pub fn add_candle(&mut self, position: Vec3) -> LightId

Add a candle.

Source

pub fn add_led_strip( &mut self, from: Vec3, to: Vec3, color: Vec3, segment_count: u32, ) -> Vec<LightId>

Add an LED strip across a line segment.

Trait Implementations§

Source§

impl Default for LightManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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>

Convert 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)

Convert &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)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,