Struct AmbientLight

Source
pub struct AmbientLight {
    pub intensity: f32,
    pub color: Srgba,
    pub environment: Option<Environment>,
}
Expand description

A light which shines on all surfaces. Can be uniform (a light that shines equally on any surface) or calculated from an environment map using the Environment struct.

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: Srgba

The base color of the light.

§environment: Option<Environment>

The light shining from the environment. This is calculated based on an environment map.

Implementations§

Source§

impl AmbientLight

Source

pub fn new(_context: &Context, intensity: f32, color: Srgba) -> Self

Constructs an ambient light that shines equally on all surfaces.

Source

pub fn new_with_environment( context: &Context, intensity: f32, color: Srgba, environment_map: &TextureCubeMap, ) -> Self

Constructs an ambient light that shines based on the given environment map.

Trait Implementations§

Source§

impl Default for AmbientLight

Source§

fn default() -> Self

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

impl Light for AmbientLight

Source§

fn shader_source(&self, i: u32) -> String

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.
Source§

fn use_uniforms(&self, program: &Program, _i: u32)

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

fn id(&self) -> LightId

Returns a unique ID for each variation of the shader source returned from Light::shader_source. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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> AutoreleaseSafe for T
where T: ?Sized,