pub struct SpotLight {
    pub intensity: f32,
    pub color: Color,
    pub position: Vec3,
    pub direction: Vec3,
    pub cutoff: Radians,
    pub attenuation: Attenuation,
    /* private fields */
}
Expand description

A light which shines from the given position and in the given direction. The light will cast shadows if you generate a shadow map.

Fields

intensity: f32

The intensity of the light. This allows for higher intensity than 1 which can be used to simulate high intensity light sources like the sun.

color: Color

The base color of the light.

position: Vec3

The position of the light.

direction: Vec3

The direction the light shines.

cutoff: Radians

The cutoff angle for the light.

attenuation: Attenuation

The Attenuation of the light.

Implementations

Constructs a new spot light.

👎 Deprecated
👎 Deprecated
👎 Deprecated
👎 Deprecated
👎 Deprecated
👎 Deprecated
👎 Deprecated
👎 Deprecated
👎 Deprecated
👎 Deprecated
👎 Deprecated
👎 Deprecated

Clear the shadow map, effectively disable the shadow. Only necessary if you want to disable the shadow, if you want to update the shadow, just use SpotLight::generate_shadow_map.

Generate a shadow map which is used to simulate shadows from the spot light onto the geometries given as input. It is recomended that the texture size is power of 2. If the shadows are too low resolution (the edges between shadow and non-shadow are pixelated) try to increase the texture size.

Returns a reference to the shadow map if it has been generated.

Trait Implementations

The fragment shader source for calculating this lights contribution to the color in a fragment. It should contain a function with this signature vec3 calculate_lighting{}(vec3 surface_color, vec3 position, vec3 normal, vec3 view_direction, float metallic, float roughness, float occlusion) Where {} is replaced with the number i given as input. This function should return the color contribution for this light on the surface with the given surface parameters. Read more

Should bind the uniforms that is needed for calculating this lights contribution to the color in Light::shader_source.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

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

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

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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

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