Extract renderer into own packege
This commit is contained in:
parent
b3fdef8837
commit
c517a836ee
24 changed files with 332 additions and 157 deletions
|
|
@ -4,5 +4,4 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
rand = "0.8.5"
|
||||
ray-tracing-core = { path = "../ray-tracing-core" }
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use rand::Rng;
|
||||
use ray_tracing_core::prelude::*;
|
||||
|
||||
pub struct DefaultMaterial {}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
use rand::Rng;
|
||||
use ray_tracing_core::prelude::*;
|
||||
|
||||
pub struct DiffuseMaterial {
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
pub mod default;
|
||||
pub mod diffuse;
|
||||
|
||||
pub mod mirror;
|
||||
|
|
|
|||
23
ray-tracing-material/src/mirror.rs
Normal file
23
ray-tracing-material/src/mirror.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue