From 42f3daefaa2dcebe91cbfbb90c2e3f804aa6f5a2 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Thu, 21 Sep 2023 10:25:23 -0700 Subject: [PATCH] Random WIP --- rtiow/renderer/src/parser.rs | 16 ++++++++- rtiow/renderer/src/renderer.rs | 7 +++- rtiow/tracer/configs/test.toml | 65 +++++++++++++++++++++++----------- 3 files changed, 66 insertions(+), 22 deletions(-) diff --git a/rtiow/renderer/src/parser.rs b/rtiow/renderer/src/parser.rs index fdd346b..372f079 100644 --- a/rtiow/renderer/src/parser.rs +++ b/rtiow/renderer/src/parser.rs @@ -4,11 +4,12 @@ use crate::{ cuboid::Cuboid, hitable::Hit, hitable_list::HitableList, - material::{Lambertian, Material, Metal}, + material::{Dielectric, DiffuseLight, Isotropic, Lambertian, Material, Metal}, renderer::Scene, sphere::Sphere, texture::{EnvMap, Texture}, }; +use chrono::IsoWeek; use serde::Deserialize; use std::{collections::HashMap, fs::File, io::BufReader, path::PathBuf, sync::Arc}; use stl::STL; @@ -46,6 +47,10 @@ impl TryFrom for Scene { for mc in c.materials { let v: Arc = match mc.material { Materials::Metal { albedo, fuzzy } => Arc::new(Metal::new(albedo, fuzzy)), + Materials::Dielectric { ref_idx } => Arc::new(Dielectric::new(ref_idx)), + Materials::DiffuseLight { texture } => Arc::new(DiffuseLight::new(texture)), + Materials::Isotropic { texture } => Arc::new(Isotropic::new(texture)), + Materials::Lambertian { texture } => Arc::new(Lambertian::new(texture)), }; if materials.insert(mc.name.clone(), v).is_some() { return Err(ConfigError::DuplicateMaterial(mc.name)); @@ -173,6 +178,15 @@ struct MaterialConfig { enum Materials { #[serde(rename = "metal")] Metal { albedo: [f32; 3], fuzzy: f32 }, + #[serde(rename = "dielectric")] + Dielectric { ref_idx: f32 }, + // TODO(wathiede): these all take Textures, for now, only support RGB + #[serde(rename = "diffuse_light")] + DiffuseLight { texture: [f32; 3] }, + #[serde(rename = "isotropic")] + Isotropic { texture: [f32; 3] }, + #[serde(rename = "lambertian")] + Lambertian { texture: [f32; 3] }, } #[derive(Debug, Deserialize)] diff --git a/rtiow/renderer/src/renderer.rs b/rtiow/renderer/src/renderer.rs index c2023b8..535f09d 100644 --- a/rtiow/renderer/src/renderer.rs +++ b/rtiow/renderer/src/renderer.rs @@ -111,7 +111,12 @@ pub struct Opt { pub use_accel: bool, /// Output directory - #[structopt(parse(from_os_str), default_value = "/tmp/tracer")] + #[structopt( + short = "o", + long = "output", + parse(from_os_str), + default_value = "/tmp/tracer" + )] pub output: PathBuf, } diff --git a/rtiow/tracer/configs/test.toml b/rtiow/tracer/configs/test.toml index 7bd2925..298967b 100644 --- a/rtiow/tracer/configs/test.toml +++ b/rtiow/tracer/configs/test.toml @@ -1,49 +1,74 @@ [scene] width = 768 -height = 768 -#subsamples = 1000 +height = 512 +subsamples = 100 [camera] -lookfrom = [0.0, 30.0, -100.0] -lookat = [0.0, 0.0, 0.0] +lookfrom = [0.0, 50.0, 100.0] +lookat = [0.0, 10.0, 0.0] fov = 45 aperture = 0.0 focus_dist = 10.0 time_min = 0.0 time_max = 1.0 +[[materials]] +name = "light1" +type = "isotropic" +texture = [20, 10, 10] +[[materials]] +name = "yellow" +type = "isotropic" +texture = [1, 1, 0] +[[materials]] +name = "magenta" +type = "lambertian" +texture = [1, 0, 1] [[materials]] name = "green" -type = "metal" -albedo = [0, 1, 0] -fuzzy = 1.5 +type = "diffuse_light" +texture = [0, 1, 0] [[materials]] -name = "blue" +name = "metal" type = "metal" -albedo = [0, 0, 1] -fuzzy = 1.5 +albedo = [1, 1, 1] +fuzzy = 0 [[materials]] -name = "red" -type = "metal" -albedo = [1, 0, 0] -fuzzy = 1.5 +name = "glass" +type = "dielectric" +ref_idx = 1.5 [[hitables]] -type = "cuboid" -min = [-10.0, -10.0, -10.0] -max = [10.0, 10.0, 10.0] -material_name = "green" +type = "sphere" +center = [-30.0, 0.0, 0.0] +radius = 10 +material_name = "yellow" [[hitables]] type = "sphere" center = [30.0, 0.0, 0.0] radius = 10 -material_name = "blue" +material_name = "green" +[[hitables]] +type = "sphere" +center = [0.0, -10.0, 0.0] +radius = 10 +material_name = "metal" +[[hitables]] +type = "sphere" +center = [0.0, 0.0, -30.0] +radius = 10 +material_name = "magenta" [[hitables]] type = "stl" path = "/net/nasx.h.xinu.tv/x/3dprint/stl/stanford_dragon.stl" scale = 200 -material_name = "red" +material_name = "glass" +#[[hitables]] +#type = "sphere" +#center = [0.0, 50.0, -100.0] +#radius = 10 +#material_name = "light1" [envmap] path = "/home/wathiede/src/xinu.tv/raytracers/rtiow/renderer/images/52681723945_e1d94d3df9_6k.jpg"