pub struct Light2d {
pub position: Vec2,
pub radius: f32,
pub color: [f32; 3],
pub energy: f32,
pub falloff: LightFalloff,
pub blend: LightBlend,
pub shadows: bool,
pub shadow_filter: ShadowFilter,
pub shadow_softness: f32,
pub light_mask: u32,
}Expand description
A point light (Godot PointLight2D) in world space.
See the module docs for the shading contract. A light with a non-finite
position, a non-positive radius/half_extent, an empty/descending stop
list, or an all-zero light_mask is dropped by plan_lighting with a
typed issue rather than shaded half-way.
Fields§
§position: Vec2World-space light centre.
radius: f32World-unit radius: the ramp’s 1.0, the shadow extrusion’s bound, and
the discard radius for LightFalloff::Stops (ignored when the
falloff is a texture, whose footprint sets its own extent, but still
used for nothing else).
color: [f32; 3]Peak light colour (linear rgb).
energy: f32Brightness multiplier applied to the ramped colour.
falloff: LightFalloffRadial ramp or falloff texture.
blend: LightBlendHow the light combines with the lit result.
shadows: boolCast shadows from the occluders whose mask it shares.
shadow_filter: ShadowFilterShadow edge filtering.
shadow_softness: f32Penumbra width in world units for ShadowFilter::Pcf4; ignored when
the filter is ShadowFilter::None.
light_mask: u32Layer bits this light lights and shadows cast against 0 = nothing.
Implementations§
Source§impl Light2d
impl Light2d
Sourcepub fn point(position: Vec2, radius: f32) -> Self
pub fn point(position: Vec2, radius: f32) -> Self
A white additive light with the default ramp.
Sourcepub fn falloff_at(&self, t: f32) -> Option<[f32; 4]>
pub fn falloff_at(&self, t: f32) -> Option<[f32; 4]>
Ramp value at normalized distance t for a stops falloff, or None
when the falloff is a texture (nothing to evaluate on the CPU).
Sourcepub fn texture_uv(&self, world: Vec2) -> Vec2
pub fn texture_uv(&self, world: Vec2) -> Vec2
Light-local uv of a world point for a texture falloff: (0,0) is the
texture’s top-left, (1,1) its bottom-right, outside 0..=1 is off
the light. Meaningless (but finite) for a stops falloff.
Trait Implementations§
impl StructuralPartialEq for Light2d
Auto Trait Implementations§
impl Freeze for Light2d
impl RefUnwindSafe for Light2d
impl Send for Light2d
impl Sync for Light2d
impl Unpin for Light2d
impl UnsafeUnpin for Light2d
impl UnwindSafe for Light2d
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
impl<T> Brush for T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.