aboutsummaryrefslogtreecommitdiff
path: root/src/camera
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-02-02 20:39:32 +0100
committerJulian T <julian@jtle.dk>2021-02-02 20:39:32 +0100
commit2b4adacea3c76b8b33dc5f50d296dd4a61107c16 (patch)
tree905b672e4005b29dad5807060ae3a966d4a3d264 /src/camera
parentd79d5d18c8281cce1e782892e5f85680906481dd (diff)
Added documentation for many of the modules
Diffstat (limited to 'src/camera')
-rw-r--r--src/camera/film.rs20
-rw-r--r--src/camera/mod.rs8
2 files changed, 26 insertions, 2 deletions
diff --git a/src/camera/film.rs b/src/camera/film.rs
index 1d87399..30fd2fe 100644
--- a/src/camera/film.rs
+++ b/src/camera/film.rs
@@ -1,19 +1,28 @@
use crate::core::*;
use crate::Float;
+/// Contains the necesary values when doing calculations
+///
+/// This is not the final RGB value
#[derive(Clone)]
pub struct Pixel {
+ /// The sum of the collected samples
rgb: Spectrum,
+ /// The amount of samples collected
samples: u32,
}
pub struct Film {
size: Vector2i,
- drawingBound: Bound2i,
+ drawing_bound: Bound2i,
pixels: Vec<Pixel>,
}
+/// FilmTile is a small version of the Film used when rendering
+///
+/// This means that multiple threads can work on the same area and commit their changed when they
+/// are done.
pub struct FilmTile {
bounds: Bound2i,
size: Vector2i,
@@ -49,11 +58,14 @@ impl Film {
let area = size.x * size.y;
Film {
size,
- drawingBound: Bound2i::new(&Vector2i::new(0), &size),
+ drawing_bound: Bound2i::new(&Vector2i::new(0), &size),
pixels: vec![Pixel::new(); area as usize],
}
}
+ /// Creates a new FilmTile from the specified bounds
+ ///
+ /// This tile can later be commited with the commit_tile function
pub fn get_tile(&self, bound: &Bound2i) -> FilmTile {
FilmTile::new(
bound,
@@ -61,6 +73,9 @@ impl Film {
}
+ /// Commit a tile back on the film
+ ///
+ /// This will lock the Film while the changes from the Tile is written
pub fn commit_tile(&mut self, tile: &FilmTile) {
let offset = tile.bounds.min;
@@ -88,6 +103,7 @@ impl FilmTile {
}
}
+ /// Add a single sample sampled from the scene
pub fn add_sample(&mut self, point: &Vector2f, c: Spectrum) {
let point = Vector2i::from(point.floor());
// Subtract the offset
diff --git a/src/camera/mod.rs b/src/camera/mod.rs
index 42de3b3..4865a36 100644
--- a/src/camera/mod.rs
+++ b/src/camera/mod.rs
@@ -1,2 +1,10 @@
+//! Implements how light is captured on film and how rays are generated
+//!
+//! The Film module specifies how calculated spectrum values contribute to the final image.
+//!
+//! The Camera class generated rays that can be cast into the scene.
+//! This requires converting the film coordinates into real coordinates
+
pub mod film;
//pub mod filter;
+//pub mod camera;