pub struct AmbientLight {
pub intensity: f32,
pub color: Color,
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: f32The 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: ColorThe base color of the light.
environment: Option<Environment>The light shining from the environment. This is calculated based on an environment map.
Implementations
sourceimpl AmbientLight
impl AmbientLight
sourcepub fn new(
_context: &Context,
intensity: f32,
color: Color
) -> ThreeDResult<Self>
pub fn new(
_context: &Context,
intensity: f32,
color: Color
) -> ThreeDResult<Self>
Constructs an ambient light that shines equally on all surfaces.
sourcepub fn new_with_environment(
context: &Context,
intensity: f32,
color: Color,
environment_map: &TextureCubeMap
) -> ThreeDResult<Self>
pub fn new_with_environment(
context: &Context,
intensity: f32,
color: Color,
environment_map: &TextureCubeMap
) -> ThreeDResult<Self>
Constructs an ambient light that shines based on the given environment map.
Trait Implementations
sourceimpl Default for AmbientLight
impl Default for AmbientLight
sourceimpl Light for AmbientLight
impl Light for AmbientLight
sourcefn shader_source(&self, i: u32) -> String
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. Read more
sourcefn use_uniforms(&self, program: &Program, _i: u32) -> ThreeDResult<()>
fn use_uniforms(&self, program: &Program, _i: u32) -> ThreeDResult<()>
Should bind the uniforms that is needed for calculating this lights contribution to the color in Light::shader_source.
Auto Trait Implementations
impl !RefUnwindSafe for AmbientLight
impl !Send for AmbientLight
impl !Sync for AmbientLight
impl Unpin for AmbientLight
impl !UnwindSafe for AmbientLight
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more