1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! This is a port of the excellent [GLSL_Pathtracer](https://github.com/knightcrawler25/GLSL-PathTracer) to Rust utilizing an abstracted, trait based backend.
//! Perfect for rendering procedural content.
//!

extern crate nalgebra_glm as glm;

/// Either f32 or f64
pub type PTF = f64;
pub type PTF2 = glm::DVec2;
pub type PTF3 = glm::DVec3;
pub type PTF4 = glm::DVec4;
const PI : PTF = std::f64::consts::PI;
const INV_PI : PTF = 1.0 / std::f64::consts::PI;
const TWO_PI : PTF = std::f64::consts::PI * 2.0;

// pub type PTF = f32;
// pub type PTF2 = glm::Vec2;
// pub type PTF3 = glm::Vec3;
// pub type PTF4 = glm::Vec4;
// const PI : PTF = std::f32::consts::PI;
// const INV_PI : PTF = 1.0 / std::f32::consts::PI;
// const TWO_PI : PTF = std::f32::consts::PI * 2.0;

/// Rays are stored in an array [origin, direction]
pub type Ray = [PTF3; 2];

pub mod tracer;
pub mod camera;
pub mod scene;
pub mod material;
pub mod globals;
pub mod buffer;
pub mod light;

pub mod prelude {
    pub use crate::PTF;
    pub use crate::PTF2;
    pub use crate::PTF3;
    pub use crate::PTF4;
    pub use crate::Ray;

    pub use nalgebra::*;

    pub use crate::camera::Camera3D;
    pub use crate::camera::pinhole::Pinhole;

    pub use crate::light::AnalyticalLight;

    pub use crate::material::*;
    pub use crate::globals::*;

    pub use crate::buffer::ColorBuffer;

    pub use crate::scene::Scene;
    pub use crate::tracer::Tracer;
}