Move Material to new module && TriangleBVH intersect && Seperate light and material
This commit is contained in:
parent
50d3874467
commit
b3fdef8837
18 changed files with 180 additions and 90 deletions
8
ray-tracing-material/Cargo.toml
Normal file
8
ray-tracing-material/Cargo.toml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "ray-tracing-material"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.5"
|
||||
ray-tracing-core = { path = "../ray-tracing-core" }
|
||||
11
ray-tracing-material/src/default.rs
Normal file
11
ray-tracing-material/src/default.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
use rand::Rng;
|
||||
use ray_tracing_core::prelude::*;
|
||||
|
||||
pub struct DefaultMaterial {}
|
||||
|
||||
impl<R: Rng> Material<R> for DefaultMaterial {
|
||||
// evaluates the bsdf
|
||||
fn eval(&self, _w_in: Dir3, _w_out: Dir3, _rng: &mut R) -> Color {
|
||||
Color::black()
|
||||
}
|
||||
}
|
||||
20
ray-tracing-material/src/diffuse.rs
Normal file
20
ray-tracing-material/src/diffuse.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use rand::Rng;
|
||||
use ray_tracing_core::prelude::*;
|
||||
|
||||
pub struct DiffuseMaterial {
|
||||
pub(crate) albedo: Color,
|
||||
}
|
||||
|
||||
impl DiffuseMaterial {
|
||||
pub fn new(color: Color) -> Self {
|
||||
Self {
|
||||
albedo: color * FloatConsts::FRAC_1_PI,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<R: Rng> Material<R> for DiffuseMaterial {
|
||||
fn eval(&self, _w_in: Dir3, _w_out: Dir3, _rng: &mut R) -> Color {
|
||||
self.albedo
|
||||
}
|
||||
}
|
||||
2
ray-tracing-material/src/lib.rs
Normal file
2
ray-tracing-material/src/lib.rs
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
pub mod default;
|
||||
pub mod diffuse;
|
||||
Loading…
Add table
Add a link
Reference in a new issue