Extract renderer into own packege

This commit is contained in:
hal8174 2024-10-01 14:37:50 +02:00
parent b3fdef8837
commit c517a836ee
24 changed files with 332 additions and 157 deletions

View file

@ -4,5 +4,4 @@ version = "0.1.0"
edition = "2021"
[dependencies]
rand = "0.8.5"
ray-tracing-core = { path = "../ray-tracing-core" }

View file

@ -1,4 +1,3 @@
use rand::Rng;
use ray_tracing_core::prelude::*;
pub struct DefaultMaterial {}

View file

@ -1,4 +1,3 @@
use rand::Rng;
use ray_tracing_core::prelude::*;
pub struct DiffuseMaterial {

View file

@ -1,2 +1,4 @@
pub mod default;
pub mod diffuse;
pub mod mirror;

View file

@ -0,0 +1,23 @@
use ray_tracing_core::prelude::*;
pub struct Mirror {
color: Color,
}
impl Mirror {
pub fn new(color: Color) -> Self {
Self { color }
}
}
impl<R: Rng> Material<R> for Mirror {
fn eval(&self, _w_in: Dir3, _w_out: Dir3, _rng: &mut R) -> Color {
Color::black()
}
fn sample(&self, w_in: Dir3, _rng: &mut R) -> ray_tracing_core::material::SampleResult {
let w_out = (2.0 * Dir3::up() * w_in.y()) - w_in;
ray_tracing_core::material::SampleResult::new(w_out, self.color)
}
}