Random WIP
This commit is contained in:
parent
9430a1e7da
commit
42f3daefaa
@ -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,
|
||||
}
|
||||
|
||||
|
||||
@ -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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user