Trait three_d::renderer::light::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) -> u8;
}
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) -> u8

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 that is smaller than 0b1u8 << 7.

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) -> u8

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) -> u8

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) -> u8

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) -> u8

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) -> u8

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) -> u8

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) -> u8

Implementors§