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§
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.
Sourcefn use_uniforms(&self, program: &Program, i: u32)
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.
Sourcefn id(&self) -> LightId
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.