pub trait Material {
    fn fragment_shader_source(
        &self,
        use_vertex_colors: bool,
        lights: &[&dyn Light]
    ) -> String; fn use_uniforms(
        &self,
        program: &Program,
        camera: &Camera,
        lights: &[&dyn Light]
    ) -> ThreeDResult<()>; fn render_states(&self) -> RenderStates; fn is_transparent(&self) -> bool; }
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 render_pass.

The material can use an attribute by adding the folowing to the fragment shader source code.

  • position (in world space): in vec3 pos;
  • normal: in vec3 nor;,
  • tangent: in vec3 tang;
  • bitangent: in vec3 bitang;
  • uv coordinates: in vec2 uvs;
  • color: in vec4 col; The rendering will fail if the material requires one of these attributes and the geometry does not provide it.

Required Methods

Returns the fragment shader source for this material. Should output the final fragment color.

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

Returns the render states needed to render with this material.

Returns whether or not this material is transparent.

Implementations on Foreign Types

Implementors