aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2021-02-07 14:25:06 +0100
committerJulian T <julian@jtle.dk>2021-02-07 14:26:20 +0100
commit33e747fa1c0957546c10e4d7b490ac7fbb0fd2d2 (patch)
tree515b2b2e017329cbcada60e898fb5795fbceb5cd /src/main.rs
parenta43ab40a75e9d4c6ee3fbdd583bc93574db19124 (diff)
Abstracted lambertian into material
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs
index 1604ae3..759cbf9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,10 +1,13 @@
use pathtrace::camera::{Camera, Film, CameraSettings};
-use pathtrace::scene::Scene;
+use pathtrace::scene::{Scene, Object};
use pathtrace::trace::DefaultTracer;
use pathtrace::scene::shapes::Sphere;
-use pathtrace::core::{Vector2i, Vector3f};
+use pathtrace::core::{Vector2i, Vector3f, Spectrum};
use pathtrace::render::{RenderContext, RenderTask};
use pathtrace::sample::UniformSampler;
+use pathtrace::material::Lambertian;
+
+use std::rc::Rc;
fn main() {
let res = Vector2i::new_xy(500, 500);
@@ -17,10 +20,13 @@ fn main() {
screensize: res,
});
+ let brown = Rc::new(Lambertian::new(Spectrum::new_rgb(0.5, 0.3, 0.0)));
+ let blue = Rc::new(Lambertian::new(Spectrum::new_rgb(0.0, 0.3, 0.7)));
+
let mut scn = Scene::new();
- scn.add_shapes(vec![
- Box::new(Sphere::new(0.5, Vector3f::new_xyz(0.0, 0.0, -1.0))),
- Box::new(Sphere::new(100.0, Vector3f::new_xyz(0.0, -100.5, -1.0))),
+ scn.add_objects(vec![
+ Object::new(blue.clone(), Box::new(Sphere::new(0.5, Vector3f::new_xyz(0.0, 0.0, -1.0)))),
+ Object::new(brown.clone(), Box::new(Sphere::new(100.0, Vector3f::new_xyz(0.0, -100.5, -1.0)))),
]);
let tracer = DefaultTracer::new(&scn, None);
@@ -32,7 +38,7 @@ fn main() {
let mut film = Film::new(res);
let tile = film.get_tile(&film.frame);
- let mut task = RenderTask::new(Box::new(tile), 100);
+ let mut task = RenderTask::new(Box::new(tile), 10);
task.render(&ctx, &mut sampler);
film.commit_tile(&task.tile);