Compare commits

..

No commits in common. "93bfeb9125d0dfa9d772b9e2b57b0cef01188d36" and "51185e9e844a3a883bf3a8d9cb89dc3e451cdf02" have entirely different histories.

47 changed files with 412 additions and 380 deletions

2
.gitignore vendored
View File

@ -1,4 +1,2 @@
**/target **/target
**/*.rs.bk **/*.rs.bk
**/zig-out
**/zig-cache

View File

@ -2,7 +2,7 @@ use std::{
str::FromStr, str::FromStr,
sync::{ sync::{
mpsc::{sync_channel, Receiver, SyncSender}, mpsc::{sync_channel, Receiver, SyncSender},
Arc, Mutex, {Arc, Mutex},
}, },
thread, thread,
}; };

View File

@ -1,4 +1,6 @@
use std::{fs::File, io::BufWriter, path::Path}; use std::fs::File;
use std::io::BufWriter;
use std::path::Path;
use png; use png;
use thiserror::Error; use thiserror::Error;

View File

@ -1,7 +1,5 @@
use std::{ use std::fmt;
fmt, use std::ops::{Index, IndexMut, Mul, Sub};
ops::{Index, IndexMut, Mul, Sub},
};
use crate::{tuples::Tuple, Float, EPSILON}; use crate::{tuples::Tuple, Float, EPSILON};

View File

@ -1,6 +1,15 @@
use std::{fmt, time::SystemTime}; use std::fmt;
use std::time::SystemTime;
use actix_web::{http, middleware, server, App, HttpRequest, HttpResponse, Path, Query, Result}; use actix_web::http;
use actix_web::middleware;
use actix_web::server;
use actix_web::App;
use actix_web::HttpRequest;
use actix_web::HttpResponse;
use actix_web::Path;
use actix_web::Query;
use actix_web::Result;
use askama::Template; use askama::Template;
use log::info; use log::info;
use rand::SeedableRng; use rand::SeedableRng;
@ -8,12 +17,13 @@ use rand_xorshift::XorShiftRng;
use serde_derive::Deserialize; use serde_derive::Deserialize;
use structopt::StructOpt; use structopt::StructOpt;
use renderer::{ use renderer::noise;
noise, use renderer::noise::lode::Lode;
noise::{lode::Lode, perlin::Perlin, NoiseType}, use renderer::noise::perlin::Perlin;
texture::{NoiseTexture, Texture}, use renderer::noise::NoiseType;
vec3::Vec3, use renderer::texture::NoiseTexture;
}; use renderer::texture::Texture;
use renderer::vec3::Vec3;
#[derive(StructOpt)] #[derive(StructOpt)]
#[structopt(name = "noise_explorer", about = "CLI for exploring Perlin noise")] #[structopt(name = "noise_explorer", about = "CLI for exploring Perlin noise")]
@ -443,9 +453,16 @@ fn main() -> Result<(), std::io::Error> {
mod tests { mod tests {
use std::str; use std::str;
use actix_web::{http::Method, test::TestServer, HttpMessage, Path, Query}; use actix_web::http::Method;
use actix_web::test::TestServer;
use actix_web::HttpMessage;
use actix_web::Path;
use actix_web::Query;
use super::{NoiseParamsMarble, NoiseParamsScale, NoiseParamsTurbulence, OptionalParams}; use super::NoiseParamsMarble;
use super::NoiseParamsScale;
use super::NoiseParamsTurbulence;
use super::OptionalParams;
#[test] #[test]
fn noise_param_from_req() { fn noise_param_from_req() {

View File

@ -1,12 +1,15 @@
#[macro_use] #[macro_use]
extern crate criterion; extern crate criterion;
use criterion::{Criterion, ParameterizedBenchmark}; use criterion::Criterion;
use criterion::ParameterizedBenchmark;
use rtiow::{ use rtiow::hitable::Hit;
hitable::Hit, material::Lambertian, ray::Ray, sphere::Sphere, texture::ConstantTexture, use rtiow::material::Lambertian;
vec3::Vec3, use rtiow::ray::Ray;
}; use rtiow::sphere::Sphere;
use rtiow::texture::ConstantTexture;
use rtiow::vec3::Vec3;
fn criterion_benchmark(c: &mut Criterion) { fn criterion_benchmark(c: &mut Criterion) {
let sphere = Sphere::new( let sphere = Sphere::new(

View File

@ -1,6 +1,7 @@
use std::fmt; use std::fmt;
use crate::{ray::Ray, vec3::Vec3}; use crate::ray::Ray;
use crate::vec3::Vec3;
#[derive(Debug, Clone, PartialEq)] #[derive(Debug, Clone, PartialEq)]
pub struct AABB { pub struct AABB {

View File

@ -1,13 +1,16 @@
use std::{self, fmt, time::Instant}; use std;
use std::fmt;
use std::time::Instant;
use log::info; use log::info;
use rand::{self, Rng}; use rand;
use rand::Rng;
use crate::{ use crate::aabb::surrounding_box;
aabb::{surrounding_box, AABB}, use crate::aabb::AABB;
hitable::{Hit, HitRecord}, use crate::hitable::Hit;
ray::Ray, use crate::hitable::HitRecord;
}; use crate::ray::Ray;
enum BVHNode { enum BVHNode {
Leaf(Box<dyn Hit>), Leaf(Box<dyn Hit>),
@ -229,13 +232,12 @@ impl Hit for BVH {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::{ use crate::aabb::AABB;
aabb::AABB, use crate::material::Lambertian;
material::{Lambertian, Metal}, use crate::material::Metal;
sphere::Sphere, use crate::sphere::Sphere;
texture::ConstantTexture, use crate::texture::ConstantTexture;
vec3::Vec3, use crate::vec3::Vec3;
};
use super::*; use super::*;

View File

@ -1,11 +1,11 @@
use std::f32::consts::PI; use std::f32::consts::PI;
use rand::{self, Rng}; use rand;
use rand::Rng;
use crate::{ use crate::ray::Ray;
ray::Ray, use crate::vec3::cross;
vec3::{cross, Vec3}, use crate::vec3::Vec3;
};
fn random_in_unit_disk() -> Vec3 { fn random_in_unit_disk() -> Vec3 {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();

View File

@ -1,15 +1,15 @@
use std; use std;
use rand::{self, Rng}; use rand;
use rand::Rng;
use crate::{ use crate::aabb::AABB;
aabb::AABB, use crate::hitable::Hit;
hitable::{Hit, HitRecord}, use crate::hitable::HitRecord;
material::Isotropic, use crate::material::Isotropic;
ray::Ray, use crate::ray::Ray;
texture::Texture, use crate::texture::Texture;
vec3::Vec3, use crate::vec3::Vec3;
};
pub struct ConstantMedium<H, T> pub struct ConstantMedium<H, T>
where where

View File

@ -1,15 +1,16 @@
use std::sync::Arc; use std::sync::Arc;
use crate::{ use crate::aabb::AABB;
aabb::AABB, use crate::flip_normals::FlipNormals;
flip_normals::FlipNormals, use crate::hitable::Hit;
hitable::{Hit, HitRecord}, use crate::hitable::HitRecord;
hitable_list::HitableList, use crate::hitable_list::HitableList;
material::Material, use crate::material::Material;
ray::Ray, use crate::ray::Ray;
rect::{XYRect, XZRect, YZRect}, use crate::rect::XYRect;
vec3::Vec3, use crate::rect::XZRect;
}; use crate::rect::YZRect;
use crate::vec3::Vec3;
pub struct Cuboid { pub struct Cuboid {
p_min: Vec3, p_min: Vec3,

View File

@ -1,8 +1,7 @@
use crate::{ use crate::aabb::AABB;
aabb::AABB, use crate::hitable::Hit;
hitable::{Hit, HitRecord}, use crate::hitable::HitRecord;
ray::Ray, use crate::ray::Ray;
};
pub struct FlipNormals<H> pub struct FlipNormals<H>
where where

View File

@ -1,6 +1,9 @@
use std::sync::Arc; use std::sync::Arc;
use crate::{aabb::AABB, material::Material, ray::Ray, vec3::Vec3}; use crate::aabb::AABB;
use crate::material::Material;
use crate::ray::Ray;
use crate::vec3::Vec3;
pub struct HitRecord<'m> { pub struct HitRecord<'m> {
pub t: f32, pub t: f32,

View File

@ -1,11 +1,11 @@
use std; use std;
use crate::{ use crate::aabb::surrounding_box;
aabb::{surrounding_box, AABB}, use crate::aabb::AABB;
hitable::{Hit, HitRecord}, use crate::hitable::Hit;
ray::Ray, use crate::hitable::HitRecord;
vec3::Vec3, use crate::ray::Ray;
}; use crate::vec3::Vec3;
#[derive(Default)] #[derive(Default)]
pub struct HitableList { pub struct HitableList {

View File

@ -2,11 +2,11 @@ use std::fmt;
use log::info; use log::info;
use crate::{ use crate::aabb::surrounding_box;
aabb::{surrounding_box, AABB}, use crate::aabb::AABB;
hitable::{Hit, HitRecord}, use crate::hitable::Hit;
ray::Ray, use crate::hitable::HitRecord;
}; use crate::ray::Ray;
pub enum KDTree { pub enum KDTree {
Leaf(Box<dyn Hit>), Leaf(Box<dyn Hit>),

View File

@ -1,13 +1,13 @@
use std::sync::Arc; use std::sync::Arc;
use rand::{self, Rng}; use rand;
use rand::Rng;
use crate::{ use crate::hitable::HitRecord;
hitable::HitRecord, use crate::ray::Ray;
ray::Ray, use crate::texture::Texture;
texture::Texture, use crate::vec3::dot;
vec3::{dot, Vec3}, use crate::vec3::Vec3;
};
fn random_in_unit_sphere() -> Vec3 { fn random_in_unit_sphere() -> Vec3 {
let mut rng = rand::thread_rng(); let mut rng = rand::thread_rng();

View File

@ -1,11 +1,12 @@
use crate::{ use crate::aabb::surrounding_box;
aabb::{surrounding_box, AABB}, use crate::aabb::AABB;
hitable::{Hit, HitRecord}, use crate::hitable::Hit;
material::Material, use crate::hitable::HitRecord;
ray::Ray, use crate::material::Material;
sphere::get_sphere_uv, use crate::ray::Ray;
vec3::{dot, Vec3}, use crate::sphere::get_sphere_uv;
}; use crate::vec3::dot;
use crate::vec3::Vec3;
pub struct MovingSphere<M> pub struct MovingSphere<M>
where where

View File

@ -2,7 +2,8 @@ use log::trace;
/// Implements the concepts from https://lodev.org/cgtutor/randomnoise.html /// Implements the concepts from https://lodev.org/cgtutor/randomnoise.html
use rand; use rand;
use crate::{noise::NoiseSource, vec3::Vec3}; use crate::noise::NoiseSource;
use crate::vec3::Vec3;
const NOISE_SIZE: usize = 128; const NOISE_SIZE: usize = 128;
pub struct Lode { pub struct Lode {

View File

@ -1,12 +1,12 @@
// There are many math functions in this file, so we allow single letter variable names. // There are many math functions in this file, so we allow single letter variable names.
#![allow(clippy::many_single_char_names)] #![allow(clippy::many_single_char_names)]
use log::trace; use log::trace;
use rand::{seq::SliceRandom, Rng}; use rand::seq::SliceRandom;
use rand::Rng;
use crate::{ use crate::noise::NoiseSource;
noise::NoiseSource, use crate::vec3::dot;
vec3::{dot, Vec3}, use crate::vec3::Vec3;
};
pub struct Perlin { pub struct Perlin {
ran_vec: Vec<Vec3>, ran_vec: Vec<Vec3>,

View File

@ -1,11 +1,10 @@
use std::{ use std::collections::HashMap;
collections::HashMap, use std::fs::File;
fs::File, use std::io::BufWriter;
io::BufWriter, use std::path::Path;
path::Path, use std::sync::Arc;
sync::{Arc, Mutex}, use std::sync::Mutex;
time, use std::time;
};
use chrono::Local; use chrono::Local;
use image; use image;
@ -13,7 +12,8 @@ use lazy_static::lazy_static;
use log::info; use log::info;
use serde_derive::Serialize; use serde_derive::Serialize;
use crate::{renderer::Scene, vec3::Vec3}; use crate::renderer::Scene;
use crate::vec3::Vec3;
// Main RGB image output from rendering the scene. // Main RGB image output from rendering the scene.
pub const MAIN_IMAGE: &str = "@final"; pub const MAIN_IMAGE: &str = "@final";

View File

@ -1,12 +1,11 @@
// There are many math functions in this file, so we allow single letter variable names. // There are many math functions in this file, so we allow single letter variable names.
#![allow(clippy::many_single_char_names)] #![allow(clippy::many_single_char_names)]
use crate::{ use crate::aabb::AABB;
aabb::AABB, use crate::hitable::Hit;
hitable::{Hit, HitRecord}, use crate::hitable::HitRecord;
material::Material, use crate::material::Material;
ray::Ray, use crate::ray::Ray;
vec3::Vec3, use crate::vec3::Vec3;
};
pub struct XYRect<M> pub struct XYRect<M>
where where

View File

@ -1,34 +1,38 @@
use std::{ use std::fmt;
fmt, use std::ops::AddAssign;
ops::{AddAssign, Range}, use std::ops::Range;
path::{Path, PathBuf}, use std::path::Path;
str, sync, use std::path::PathBuf;
sync::{ use std::str;
mpsc::{sync_channel, Receiver, SyncSender}, use std::sync;
Arc, Mutex, use std::sync::mpsc::sync_channel;
}, use std::sync::mpsc::Receiver;
thread, time, use std::sync::mpsc::SyncSender;
}; use std::sync::Arc;
use std::sync::Mutex;
use std::thread;
use std::time;
use core_affinity; use core_affinity;
use log::{info, trace}; use log::info;
use log::trace;
use num_cpus; use num_cpus;
use rand::{self, Rng}; use rand;
use rand::Rng;
use serde_derive::Serialize; use serde_derive::Serialize;
use structopt::StructOpt; use structopt::StructOpt;
use crate::{ use crate::camera::Camera;
camera::Camera, use crate::hitable::Hit;
hitable::Hit, use crate::human;
human, use crate::material::Lambertian;
material::Lambertian, use crate::output;
output, use crate::ray::Ray;
ray::Ray, use crate::scenes;
scenes, use crate::sphere::Sphere;
sphere::Sphere, use crate::texture::ConstantTexture;
texture::{ConstantTexture, EnvMap}, use crate::texture::EnvMap;
vec3::Vec3, use crate::vec3::Vec3;
};
#[derive(Debug)] #[derive(Debug)]
pub enum Model { pub enum Model {

View File

@ -1,11 +1,12 @@
use std::f32::{consts::PI, MAX, MIN}; use std::f32::consts::PI;
use std::f32::MAX;
use std::f32::MIN;
use crate::{ use crate::aabb::AABB;
aabb::AABB, use crate::hitable::Hit;
hitable::{Hit, HitRecord}, use crate::hitable::HitRecord;
ray::Ray, use crate::ray::Ray;
vec3::Vec3, use crate::vec3::Vec3;
};
pub struct RotateY<H> pub struct RotateY<H>
where where

View File

@ -1,18 +1,18 @@
use log::trace; use log::trace;
use rand::{self, Rng}; use rand;
use rand::Rng;
use crate::{ use crate::bvh::BVH;
bvh::BVH, use crate::camera::Camera;
camera::Camera, use crate::hitable::Hit;
hitable::Hit, use crate::hitable_list::HitableList;
hitable_list::HitableList, use crate::kdtree::KDTree;
kdtree::KDTree, use crate::material::Lambertian;
material::Lambertian, use crate::renderer::Opt;
renderer::{Opt, Scene}, use crate::renderer::Scene;
sphere::Sphere, use crate::sphere::Sphere;
texture::ConstantTexture, use crate::texture::ConstantTexture;
vec3::Vec3, use crate::vec3::Vec3;
};
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(20., 20., 20.); let lookfrom = Vec3::new(20., 20., 20.);

View File

@ -1,16 +1,21 @@
use rand::{self, Rng}; use rand;
use rand::Rng;
use crate::{ use crate::camera::Camera;
camera::Camera, use crate::hitable::Hit;
hitable::Hit, use crate::hitable_list::HitableList;
hitable_list::HitableList, use crate::kdtree::KDTree;
kdtree::KDTree, use crate::material::Dielectric;
material::{Dielectric, Lambertian, Material, Metal}, use crate::material::Lambertian;
renderer::{Opt, Scene}, use crate::material::Material;
sphere::Sphere, use crate::material::Metal;
texture::{CheckerTexture, ConstantTexture, EnvMap}, use crate::renderer::Opt;
vec3::Vec3, use crate::renderer::Scene;
}; use crate::sphere::Sphere;
use crate::texture::CheckerTexture;
use crate::texture::ConstantTexture;
use crate::texture::EnvMap;
use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(13., 2., 3.); let lookfrom = Vec3::new(13., 2., 3.);

View File

@ -1,16 +1,16 @@
use log::trace; use log::trace;
use crate::{ use crate::bvh::BVH;
bvh::BVH, use crate::camera::Camera;
camera::Camera, use crate::hitable::Hit;
hitable::Hit, use crate::material::Lambertian;
material::{Lambertian, Metal}, use crate::material::Metal;
moving_sphere::MovingSphere, use crate::moving_sphere::MovingSphere;
renderer::{Opt, Scene}, use crate::renderer::Opt;
sphere::Sphere, use crate::renderer::Scene;
texture::ConstantTexture, use crate::sphere::Sphere;
vec3::Vec3, use crate::texture::ConstantTexture;
}; use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(3., 3., 2.); let lookfrom = Vec3::new(3., 3., 2.);

View File

@ -1,20 +1,22 @@
use std::sync::Arc; use std::sync::Arc;
use crate::{ use crate::camera::Camera;
camera::Camera, use crate::cuboid::Cuboid;
cuboid::Cuboid, use crate::flip_normals::FlipNormals;
flip_normals::FlipNormals, use crate::hitable::Hit;
hitable::Hit, use crate::hitable_list::HitableList;
hitable_list::HitableList, use crate::kdtree::KDTree;
kdtree::KDTree, use crate::material::DiffuseLight;
material::{DiffuseLight, Lambertian}, use crate::material::Lambertian;
rect::{XYRect, XZRect, YZRect}, use crate::rect::XYRect;
renderer::{Opt, Scene}, use crate::rect::XZRect;
rotate::RotateY, use crate::rect::YZRect;
texture::ConstantTexture, use crate::renderer::Opt;
translate::Translate, use crate::renderer::Scene;
vec3::Vec3, use crate::rotate::RotateY;
}; use crate::texture::ConstantTexture;
use crate::translate::Translate;
use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(278., 278., -800.); let lookfrom = Vec3::new(278., 278., -800.);

View File

@ -1,21 +1,24 @@
use std::sync::Arc; use std::sync::Arc;
use crate::{ use crate::camera::Camera;
camera::Camera, use crate::constant_medium::ConstantMedium;
constant_medium::ConstantMedium, use crate::cuboid::Cuboid;
cuboid::Cuboid, use crate::flip_normals::FlipNormals;
flip_normals::FlipNormals, use crate::hitable::Hit;
hitable::Hit, use crate::hitable_list::HitableList;
hitable_list::HitableList, use crate::kdtree::KDTree;
kdtree::KDTree, use crate::material::DiffuseLight;
material::{DiffuseLight, Lambertian, Material}, use crate::material::Lambertian;
rect::{XYRect, XZRect, YZRect}, use crate::material::Material;
renderer::{Opt, Scene}, use crate::rect::XYRect;
rotate::RotateY, use crate::rect::XZRect;
texture::ConstantTexture, use crate::rect::YZRect;
translate::Translate, use crate::renderer::Opt;
vec3::Vec3, use crate::renderer::Scene;
}; use crate::rotate::RotateY;
use crate::texture::ConstantTexture;
use crate::translate::Translate;
use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(278., 278., -800.); let lookfrom = Vec3::new(278., 278., -800.);

View File

@ -1,26 +1,33 @@
use std::sync::Arc; use std::sync::Arc;
use image; use image;
use rand::{self, Rng}; use rand;
use rand::Rng;
use crate::{ use crate::camera::Camera;
camera::Camera, use crate::constant_medium::ConstantMedium;
constant_medium::ConstantMedium, use crate::cuboid::Cuboid;
cuboid::Cuboid, use crate::hitable::Hit;
hitable::Hit, use crate::hitable_list::HitableList;
hitable_list::HitableList, use crate::kdtree::KDTree;
kdtree::KDTree, use crate::material::Dielectric;
material::{Dielectric, DiffuseLight, Lambertian, Material, Metal}, use crate::material::DiffuseLight;
moving_sphere::MovingSphere, use crate::material::Lambertian;
noise::{perlin::Perlin, NoiseType}, use crate::material::Material;
rect::XZRect, use crate::material::Metal;
renderer::{Opt, Scene}, use crate::moving_sphere::MovingSphere;
rotate::RotateY, use crate::noise::perlin::Perlin;
sphere::Sphere, use crate::noise::NoiseType;
texture::{ConstantTexture, ImageTexture, NoiseTexture}, use crate::rect::XZRect;
translate::Translate, use crate::renderer::Opt;
vec3::Vec3, use crate::renderer::Scene;
}; use crate::rotate::RotateY;
use crate::sphere::Sphere;
use crate::texture::ConstantTexture;
use crate::texture::ImageTexture;
use crate::texture::NoiseTexture;
use crate::translate::Translate;
use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(478., 278., -600.); let lookfrom = Vec3::new(478., 278., -600.);

View File

@ -1,18 +1,24 @@
use rand; use rand;
use crate::{ use crate::camera::Camera;
camera::Camera, use crate::hitable::Hit;
hitable::Hit, use crate::hitable_list::HitableList;
hitable_list::HitableList, use crate::kdtree::KDTree;
kdtree::KDTree, use crate::material::DiffuseLight;
material::{DiffuseLight, Lambertian}, use crate::material::Lambertian;
noise::{perlin::Perlin, NoiseType}, use crate::noise::perlin::Perlin;
rect::{XYRect, XZRect, YZRect}, use crate::noise::NoiseType;
renderer::{Opt, Scene}, use crate::rect::XYRect;
sphere::Sphere, use crate::rect::XZRect;
texture::{ConstantTexture, ImageTexture, Mandelbrot, NoiseTexture}, use crate::rect::YZRect;
vec3::Vec3, use crate::renderer::Opt;
}; use crate::renderer::Scene;
use crate::sphere::Sphere;
use crate::texture::ConstantTexture;
use crate::texture::ImageTexture;
use crate::texture::Mandelbrot;
use crate::texture::NoiseTexture;
use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(20., 20., 20.); let lookfrom = Vec3::new(20., 20., 20.);

View File

@ -2,18 +2,19 @@ use std::sync::Arc;
use rand; use rand;
use crate::{ use crate::camera::Camera;
camera::Camera, use crate::hitable::Hit;
hitable::Hit, use crate::hitable_list::HitableList;
hitable_list::HitableList, use crate::kdtree::KDTree;
kdtree::KDTree, use crate::material::Lambertian;
material::Lambertian, use crate::noise::perlin::Perlin;
noise::{perlin::Perlin, NoiseType}, use crate::noise::NoiseType;
renderer::{Opt, Scene}, use crate::renderer::Opt;
sphere::Sphere, use crate::renderer::Scene;
texture::{NoiseTexture, Texture}, use crate::sphere::Sphere;
vec3::Vec3, use crate::texture::NoiseTexture;
}; use crate::texture::Texture;
use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(13., 2., 3.); let lookfrom = Vec3::new(13., 2., 3.);

View File

@ -1,15 +1,18 @@
use crate::{ use crate::camera::Camera;
camera::Camera, use crate::hitable::Hit;
hitable::Hit, use crate::hitable_list::HitableList;
hitable_list::HitableList, use crate::material::Dielectric;
material::{Dielectric, Lambertian, Metal}, use crate::material::Lambertian;
moving_sphere::MovingSphere, use crate::material::Metal;
rect::XYRect, use crate::moving_sphere::MovingSphere;
renderer::{Opt, Scene}, use crate::rect::XYRect;
sphere::Sphere, use crate::renderer::Opt;
texture::{CheckerTexture, ConstantTexture, EnvMap}, use crate::renderer::Scene;
vec3::Vec3, use crate::sphere::Sphere;
}; use crate::texture::CheckerTexture;
use crate::texture::ConstantTexture;
use crate::texture::EnvMap;
use crate::vec3::Vec3;
// Draws many spheres along each positive axis. // Draws many spheres along each positive axis.
// Blue X-positive // Blue X-positive

View File

@ -1,19 +1,24 @@
use image; use image;
use rand; use rand;
use crate::{ use crate::camera::Camera;
camera::Camera, use crate::hitable::Hit;
hitable::Hit, use crate::hitable_list::HitableList;
hitable_list::HitableList, use crate::kdtree::KDTree;
kdtree::KDTree, use crate::material::DiffuseLight;
material::{DiffuseLight, Lambertian}, use crate::material::Lambertian;
noise::{perlin::Perlin, NoiseType}, use crate::noise::perlin::Perlin;
rect::{XYRect, XZRect, YZRect}, use crate::noise::NoiseType;
renderer::{Opt, Scene}, use crate::rect::XYRect;
sphere::Sphere, use crate::rect::XZRect;
texture::{ConstantTexture, ImageTexture, NoiseTexture}, use crate::rect::YZRect;
vec3::Vec3, use crate::renderer::Opt;
}; use crate::renderer::Scene;
use crate::sphere::Sphere;
use crate::texture::ConstantTexture;
use crate::texture::ImageTexture;
use crate::texture::NoiseTexture;
use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(20., 20., 20.); let lookfrom = Vec3::new(20., 20., 20.);

View File

@ -1,15 +1,18 @@
use crate::{ use crate::camera::Camera;
camera::Camera, use crate::hitable::Hit;
hitable::Hit, use crate::hitable_list::HitableList;
hitable_list::HitableList, use crate::kdtree::KDTree;
kdtree::KDTree, use crate::material::Dielectric;
material::{Dielectric, Lambertian, Metal}, use crate::material::Lambertian;
moving_sphere::MovingSphere, use crate::material::Metal;
renderer::{Opt, Scene}, use crate::moving_sphere::MovingSphere;
sphere::Sphere, use crate::renderer::Opt;
texture::{CheckerTexture, ConstantTexture, Texture}, use crate::renderer::Scene;
vec3::Vec3, use crate::sphere::Sphere;
}; use crate::texture::CheckerTexture;
use crate::texture::ConstantTexture;
use crate::texture::Texture;
use crate::vec3::Vec3;
pub fn new(opt: &Opt) -> Scene { pub fn new(opt: &Opt) -> Scene {
let lookfrom = Vec3::new(3., 4., 2.); let lookfrom = Vec3::new(3., 4., 2.);

View File

@ -1,12 +1,12 @@
use std::f32::consts::PI; use std::f32::consts::PI;
use crate::{ use crate::aabb::AABB;
aabb::AABB, use crate::hitable::Hit;
hitable::{Hit, HitRecord}, use crate::hitable::HitRecord;
material::Material, use crate::material::Material;
ray::Ray, use crate::ray::Ray;
vec3::{dot, Vec3}, use crate::vec3::dot;
}; use crate::vec3::Vec3;
pub struct Sphere<M> pub struct Sphere<M>
where where

View File

@ -1,4 +1,5 @@
use crate::{texture::Texture, vec3::Vec3}; use crate::texture::Texture;
use crate::vec3::Vec3;
pub struct CheckerTexture<T> pub struct CheckerTexture<T>
where where

View File

@ -1,4 +1,5 @@
use crate::{texture::Texture, vec3::Vec3}; use crate::texture::Texture;
use crate::vec3::Vec3;
#[derive(Debug, PartialEq)] #[derive(Debug, PartialEq)]
pub struct ConstantTexture { pub struct ConstantTexture {

View File

@ -2,10 +2,9 @@ use std::f32;
use image::RgbImage; use image::RgbImage;
use crate::{ use crate::texture::ImageTexture;
texture::{ImageTexture, Texture}, use crate::texture::Texture;
vec3::Vec3, use crate::vec3::Vec3;
};
#[derive(Debug)] #[derive(Debug)]
pub struct EnvMap { pub struct EnvMap {

View File

@ -1,6 +1,7 @@
use image::RgbImage; use image::RgbImage;
use crate::{texture::Texture, vec3::Vec3}; use crate::texture::Texture;
use crate::vec3::Vec3;
#[derive(Debug)] #[derive(Debug)]
pub struct ImageTexture { pub struct ImageTexture {

View File

@ -1,7 +1,9 @@
#![allow(clippy::many_single_char_names)] #![allow(clippy::many_single_char_names)]
use rand::{self, Rng}; use rand;
use rand::Rng;
use crate::{texture::Texture, vec3::Vec3}; use crate::texture::Texture;
use crate::vec3::Vec3;
pub struct Mandelbrot { pub struct Mandelbrot {
palette: Vec<Vec3>, palette: Vec<Vec3>,

View File

@ -4,10 +4,12 @@ mod envmap;
mod image; mod image;
mod mandelbrot; mod mandelbrot;
mod noise; mod noise;
pub use crate::texture::{ pub use crate::texture::checker::CheckerTexture;
checker::CheckerTexture, constant::ConstantTexture, envmap::EnvMap, image::ImageTexture, pub use crate::texture::constant::ConstantTexture;
mandelbrot::Mandelbrot, noise::NoiseTexture, pub use crate::texture::envmap::EnvMap;
}; pub use crate::texture::image::ImageTexture;
pub use crate::texture::mandelbrot::Mandelbrot;
pub use crate::texture::noise::NoiseTexture;
use std::sync::Arc; use std::sync::Arc;

View File

@ -1,8 +1,7 @@
use crate::{ use crate::noise::NoiseSource;
noise::{NoiseSource, NoiseType}, use crate::noise::NoiseType;
texture::Texture, use crate::texture::Texture;
vec3::Vec3, use crate::vec3::Vec3;
};
pub struct NoiseTexture<N> pub struct NoiseTexture<N>
where where

View File

@ -1,9 +1,8 @@
use crate::{ use crate::aabb::AABB;
aabb::AABB, use crate::hitable::Hit;
hitable::{Hit, HitRecord}, use crate::hitable::HitRecord;
ray::Ray, use crate::ray::Ray;
vec3::Vec3, use crate::vec3::Vec3;
};
pub struct Translate<H> pub struct Translate<H>
where where

View File

@ -1,12 +1,16 @@
use std::{ use std::convert::From;
convert::From, use std::fmt;
fmt, use std::num::ParseFloatError;
num::ParseFloatError, use std::ops::Add;
ops::{Add, Div, Index, Mul, Neg, Sub}, use std::ops::Div;
str, use std::ops::Index;
}; use std::ops::Mul;
use std::ops::Neg;
use std::ops::Sub;
use std::str;
use serde_derive::{Deserialize, Serialize}; use serde_derive::Deserialize;
use serde_derive::Serialize;
#[derive(Default, Debug, Deserialize, Serialize, PartialEq, Copy, Clone)] #[derive(Default, Debug, Deserialize, Serialize, PartialEq, Copy, Clone)]
pub struct Vec3 { pub struct Vec3 {
@ -203,7 +207,8 @@ impl Sub for Vec3 {
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use std::{f32::consts::PI, str::FromStr}; use std::f32::consts::PI;
use std::str::FromStr;
use super::*; use super::*;

View File

@ -6,7 +6,8 @@ use cpuprofiler::PROFILER;
use log::info; use log::info;
use structopt::StructOpt; use structopt::StructOpt;
use renderer::renderer::{render, Opt}; use renderer::renderer::render;
use renderer::renderer::Opt;
#[cfg(not(feature = "profile"))] #[cfg(not(feature = "profile"))]
struct MockTimer; struct MockTimer;

View File

@ -1,34 +0,0 @@
const std = @import("std");
pub fn build(b: *std.build.Builder) void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();
const exe = b.addExecutable("zigrtiow", "src/main.zig");
exe.setTarget(target);
exe.setBuildMode(mode);
exe.install();
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
const exe_tests = b.addTest("src/main.zig");
exe_tests.setTarget(target);
exe_tests.setBuildMode(mode);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&exe_tests.step);
}

View File

@ -1,9 +0,0 @@
const std = @import("std");
pub fn main() anyerror!void {
std.log.info("All your codebase are belong to us.", .{});
}
test "basic test" {
try std.testing.expectEqual(10, 3 + 7);
}