Trait Light

Source
pub trait Light {
    // Required methods
    fn shader_source(&self, i: u32) -> String;
    fn use_uniforms(&self, program: &Program, i: u32);
    fn id(&self) -> LightId;
}
Expand description

Represents a light source.

Required Methods§

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.

Note: The last bit is reserved to internally implemented materials, so if implementing the Light trait outside of this crate, always return an id in the public use range as defined by LightId.

Implementations on Foreign Types§

Source§

impl<T: Light + ?Sized> Light for &T

Source§

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

Source§

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

Source§

fn id(&self) -> LightId

Source§

impl<T: Light + ?Sized> Light for &mut T

Source§

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

Source§

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

Source§

fn id(&self) -> LightId

Source§

impl<T: Light> Light for Box<T>

Source§

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

Source§

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

Source§

fn id(&self) -> LightId

Source§

impl<T: Light> Light for Rc<T>

Source§

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

Source§

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

Source§

fn id(&self) -> LightId

Source§

impl<T: Light> Light for Arc<RwLock<T>>

Source§

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

Source§

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

Source§

fn id(&self) -> LightId

Source§

impl<T: Light> Light for Arc<T>

Source§

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

Source§

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

Source§

fn id(&self) -> LightId

Source§

impl<T: Light> Light for RefCell<T>

Source§

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

Source§

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

Source§

fn id(&self) -> LightId

Implementors§