library: document light module
This commit is contained in:
parent
04deae1d88
commit
2aed964101
|
@ -10,6 +10,16 @@ pub struct AmbientLight {
|
|||
}
|
||||
|
||||
impl AmbientLight {
|
||||
/// Creates a new `AmbientLight`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use pathtracer::light::AmbientLight;
|
||||
/// # use pathtracer::core::color::LinearColor;
|
||||
/// #
|
||||
/// let amb_light = AmbientLight::new(LinearColor::new(1.0, 0.0, 1.0));
|
||||
/// ```
|
||||
pub fn new(color: LinearColor) -> Self {
|
||||
AmbientLight { color }
|
||||
}
|
||||
|
|
|
@ -12,6 +12,20 @@ pub struct DirectionalLight {
|
|||
}
|
||||
|
||||
impl DirectionalLight {
|
||||
/// Creates a new `DirectionalLight`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use pathtracer::light::DirectionalLight;
|
||||
/// # use pathtracer::core::color::LinearColor;
|
||||
/// # use pathtracer::Vector;
|
||||
/// #
|
||||
/// let dir_light = DirectionalLight::new(
|
||||
/// Vector::new(1.0, 0.0, 0.0),
|
||||
/// LinearColor::new(1.0, 0.0, 1.0),
|
||||
/// );
|
||||
/// ```
|
||||
pub fn new(direction: Vector, color: LinearColor) -> Self {
|
||||
DirectionalLight {
|
||||
direction: direction.normalize(),
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
//! Various light implementations
|
||||
|
||||
use super::core::LinearColor;
|
||||
use super::{Point, Vector};
|
||||
|
||||
|
|
|
@ -11,6 +11,20 @@ pub struct PointLight {
|
|||
}
|
||||
|
||||
impl PointLight {
|
||||
/// Creates a new `PointLight`.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use pathtracer::light::PointLight;
|
||||
/// # use pathtracer::core::color::LinearColor;
|
||||
/// # use pathtracer::Point;
|
||||
/// #
|
||||
/// let dir_light = PointLight::new(
|
||||
/// Point::origin(),
|
||||
/// LinearColor::new(1.0, 0.0, 1.0),
|
||||
/// );
|
||||
/// ```
|
||||
pub fn new(position: Point, color: LinearColor) -> Self {
|
||||
PointLight { position, color }
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ use crate::{Point, Vector};
|
|||
use serde::{Deserialize, Deserializer};
|
||||
|
||||
/// Represent a light emanating from a directed light-source, outputting rays in a cone.
|
||||
///
|
||||
/// The illumination cone cannot have an FOV over 180°.
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct SpotLight {
|
||||
|
|
Loading…
Reference in a new issue