library: document material module

This commit is contained in:
Antoine Martin 2020-03-22 00:24:26 +01:00
parent 2aed964101
commit 614217d33e
2 changed files with 19 additions and 0 deletions

View file

@ -1,3 +1,5 @@
//! Various material implementations
use super::core::LightProperties;
use super::Point2D;
use serde::Deserialize;
@ -5,6 +7,7 @@ use serde::Deserialize;
/// All the existing `Material` implementation.
#[serde(tag = "type")]
#[serde(rename_all = "lowercase")]
#[allow(missing_docs)]
#[enum_dispatch::enum_dispatch]
#[derive(Debug, PartialEq, Deserialize)]
pub enum MaterialEnum {

View file

@ -11,6 +11,22 @@ pub struct UniformMaterial {
}
impl UniformMaterial {
/// Creates a new `UniformMaterial`.
///
/// # Examples
///
/// ```
/// # use pathtracer::material::UniformMaterial;
/// # use pathtracer::core::{LightProperties, LinearColor};
/// #
/// let uni_mat = UniformMaterial::new(
/// LightProperties::new(
/// LinearColor::new(1.0, 0.0, 0.0), // diffuse component
/// LinearColor::new(0.0, 0.0, 0.0), // specular component
/// None,
/// ),
/// );
/// ```
pub fn new(properties: LightProperties) -> Self {
UniformMaterial { properties }
}