Extract renderer into own packege
This commit is contained in:
parent
b3fdef8837
commit
c517a836ee
24 changed files with 332 additions and 157 deletions
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