Random WIP
This commit is contained in:
@@ -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<Config> for Scene {
|
||||
for mc in c.materials {
|
||||
let v: Arc<dyn Material> = 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)]
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user