Move Material to new module && TriangleBVH intersect && Seperate light and material

This commit is contained in:
hal8174 2024-09-30 21:13:50 +02:00
parent 50d3874467
commit b3fdef8837
18 changed files with 180 additions and 90 deletions

View 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" }

View 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()
}
}

View 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
}
}

View file

@ -0,0 +1,2 @@
pub mod default;
pub mod diffuse;