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