library: core: document light_properties module
This commit is contained in:
parent
b71f0aee5a
commit
2c6e0b42d2
|
@ -1,9 +1,13 @@
|
||||||
|
//! Light property coefficients (diffuse, specular, transparency, reflectivity...)
|
||||||
|
|
||||||
use super::color::LinearColor;
|
use super::color::LinearColor;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone, Deserialize)]
|
#[derive(Debug, PartialEq, Clone, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
|
/// This enum stores the reflectivity or transparency information.
|
||||||
pub enum ReflTransEnum {
|
pub enum ReflTransEnum {
|
||||||
|
/// Transparence properties.
|
||||||
Transparency {
|
Transparency {
|
||||||
/// The transparency coefficient.
|
/// The transparency coefficient.
|
||||||
#[serde(rename = "transparency")]
|
#[serde(rename = "transparency")]
|
||||||
|
@ -11,6 +15,7 @@ pub enum ReflTransEnum {
|
||||||
/// The diffraction index.
|
/// The diffraction index.
|
||||||
index: f32,
|
index: f32,
|
||||||
},
|
},
|
||||||
|
/// Reflectivity properties.
|
||||||
Reflectivity {
|
Reflectivity {
|
||||||
/// The reflectivity coefficient.
|
/// The reflectivity coefficient.
|
||||||
#[serde(rename = "reflectivity")]
|
#[serde(rename = "reflectivity")]
|
||||||
|
@ -31,6 +36,20 @@ pub struct LightProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LightProperties {
|
impl LightProperties {
|
||||||
|
/// Creates a new `LightProperties` struct.
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// # use pathtracer::core::light_properties::{LightProperties, ReflTransEnum};
|
||||||
|
/// # use pathtracer::core::color::LinearColor;
|
||||||
|
/// #
|
||||||
|
/// let lp = LightProperties::new(
|
||||||
|
/// LinearColor::new(0.25, 0.5, 1.),
|
||||||
|
/// LinearColor::new(0.75, 0.375, 0.125),
|
||||||
|
/// Some(ReflTransEnum::Reflectivity { coef: 0.5 }),
|
||||||
|
/// );
|
||||||
|
/// ```
|
||||||
pub fn new(
|
pub fn new(
|
||||||
diffuse: LinearColor,
|
diffuse: LinearColor,
|
||||||
specular: LinearColor,
|
specular: LinearColor,
|
||||||
|
|
Loading…
Reference in a new issue