pub trait Material {
    // Required methods
    fn fragment_shader_source(&self, lights: &[&dyn Light]) -> String;
    fn id(&self) -> u16;
    fn fragment_attributes(&self) -> FragmentAttributes;
    fn use_uniforms(
        &self,
        program: &Program,
        camera: &Camera,
        lights: &[&dyn Light]
    );
    fn render_states(&self) -> RenderStates;
    fn material_type(&self) -> MaterialType;
}
Expand description

Represents a material that, together with a geometry, can be rendered using Geometry::render_with_material. Alternatively, a geometry and a material can be combined in a Gm, thereby creating an Object which can be used in a render call, for example RenderTarget::render.

Required Methods§

source

fn fragment_shader_source(&self, lights: &[&dyn Light]) -> String

Returns the fragment shader source for this material.

source

fn id(&self) -> u16

Returns a unique ID for each variation of the shader source returned from Material::fragment_shader_source.

Note: The last bit is reserved to internally implemented materials, so if implementing the Material trait outside of this crate, always return an id that is smaller than 0b1u16 << 15.

source

fn fragment_attributes(&self) -> FragmentAttributes

Returns a FragmentAttributes struct that describes which fragment attributes, ie. the input from the vertex shader, are required for rendering with this material.

source

fn use_uniforms( &self, program: &Program, camera: &Camera, lights: &[&dyn Light] )

Sends the uniform data needed for this material to the fragment shader.

source

fn render_states(&self) -> RenderStates

Returns the render states needed to render with this material.

source

fn material_type(&self) -> MaterialType

Returns the type of material.

Implementations on Foreign Types§

source§

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

source§

fn fragment_shader_source(&self, lights: &[&dyn Light]) -> String

source§

fn fragment_attributes(&self) -> FragmentAttributes

source§

fn use_uniforms( &self, program: &Program, camera: &Camera, lights: &[&dyn Light] )

source§

fn render_states(&self) -> RenderStates

source§

fn material_type(&self) -> MaterialType

source§

fn id(&self) -> u16

source§

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

source§

fn fragment_shader_source(&self, lights: &[&dyn Light]) -> String

source§

fn fragment_attributes(&self) -> FragmentAttributes

source§

fn use_uniforms( &self, program: &Program, camera: &Camera, lights: &[&dyn Light] )

source§

fn render_states(&self) -> RenderStates

source§

fn material_type(&self) -> MaterialType

source§

fn id(&self) -> u16

source§

impl<T: Material> Material for Box<T>

source§

fn fragment_shader_source(&self, lights: &[&dyn Light]) -> String

source§

fn fragment_attributes(&self) -> FragmentAttributes

source§

fn use_uniforms( &self, program: &Program, camera: &Camera, lights: &[&dyn Light] )

source§

fn render_states(&self) -> RenderStates

source§

fn material_type(&self) -> MaterialType

source§

fn id(&self) -> u16

source§

impl<T: Material> Material for Rc<T>

source§

fn fragment_shader_source(&self, lights: &[&dyn Light]) -> String

source§

fn fragment_attributes(&self) -> FragmentAttributes

source§

fn use_uniforms( &self, program: &Program, camera: &Camera, lights: &[&dyn Light] )

source§

fn render_states(&self) -> RenderStates

source§

fn material_type(&self) -> MaterialType

source§

fn id(&self) -> u16

source§

impl<T: Material> Material for Arc<T>

source§

fn fragment_shader_source(&self, lights: &[&dyn Light]) -> String

source§

fn fragment_attributes(&self) -> FragmentAttributes

source§

fn use_uniforms( &self, program: &Program, camera: &Camera, lights: &[&dyn Light] )

source§

fn render_states(&self) -> RenderStates

source§

fn material_type(&self) -> MaterialType

source§

fn id(&self) -> u16

source§

impl<T: Material> Material for RefCell<T>

source§

fn fragment_shader_source(&self, lights: &[&dyn Light]) -> String

source§

fn fragment_attributes(&self) -> FragmentAttributes

source§

fn use_uniforms( &self, program: &Program, camera: &Camera, lights: &[&dyn Light] )

source§

fn render_states(&self) -> RenderStates

source§

fn material_type(&self) -> MaterialType

source§

fn id(&self) -> u16

source§

impl<T: Material> Material for RwLock<T>

source§

fn fragment_shader_source(&self, lights: &[&dyn Light]) -> String

source§

fn fragment_attributes(&self) -> FragmentAttributes

source§

fn use_uniforms( &self, program: &Program, camera: &Camera, lights: &[&dyn Light] )

source§

fn render_states(&self) -> RenderStates

source§

fn material_type(&self) -> MaterialType

source§

fn id(&self) -> u16

Implementors§