Improve module path usage and remove extern crate declarations where possible.
This commit is contained in:
parent
178c0bd6cb
commit
28a07de456
|
@ -1,19 +1,16 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std;
|
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::algorithm::partition;
|
use crate::{
|
||||||
use crate::bbox::BBox;
|
algorithm::partition, bbox::BBox, boundable::Boundable, lerp::lerp_slice, ray::AccelRay,
|
||||||
use crate::boundable::Boundable;
|
timer::Timer,
|
||||||
use crate::lerp::lerp_slice;
|
};
|
||||||
use crate::ray::AccelRay;
|
|
||||||
use crate::timer::Timer;
|
|
||||||
|
|
||||||
use super::bvh_base::{BVHBase, BVHBaseNode, BVH_MAX_DEPTH};
|
use super::{
|
||||||
use super::ACCEL_NODE_RAY_TESTS;
|
bvh_base::{BVHBase, BVHBaseNode, BVH_MAX_DEPTH},
|
||||||
use super::ACCEL_TRAV_TIME;
|
ACCEL_NODE_RAY_TESTS, ACCEL_TRAV_TIME,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct BVH<'a> {
|
pub struct BVH<'a> {
|
||||||
|
|
|
@ -1,20 +1,17 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std;
|
use bvh_order::{calc_traversal_code, SplitAxes, TRAVERSAL_TABLE};
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::algorithm::partition;
|
use crate::{
|
||||||
use crate::bbox::BBox;
|
algorithm::partition, bbox::BBox, boundable::Boundable, lerp::lerp_slice, ray::AccelRay,
|
||||||
use crate::boundable::Boundable;
|
timer::Timer,
|
||||||
use crate::lerp::lerp_slice;
|
};
|
||||||
use crate::ray::AccelRay;
|
|
||||||
use crate::timer::Timer;
|
|
||||||
|
|
||||||
use super::bvh_base::{BVHBase, BVHBaseNode, BVH_MAX_DEPTH};
|
use super::{
|
||||||
use super::ACCEL_NODE_RAY_TESTS;
|
bvh_base::{BVHBase, BVHBaseNode, BVH_MAX_DEPTH},
|
||||||
use super::ACCEL_TRAV_TIME;
|
ACCEL_NODE_RAY_TESTS, ACCEL_TRAV_TIME,
|
||||||
use bvh_order::{calc_traversal_code, SplitAxes, TRAVERSAL_TABLE};
|
};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct BVH4<'a> {
|
pub struct BVH4<'a> {
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use crate::algorithm::merge_slices_append;
|
use crate::{algorithm::merge_slices_append, bbox::BBox, lerp::lerp_slice, math::log2_64};
|
||||||
use crate::bbox::BBox;
|
|
||||||
use crate::lerp::lerp_slice;
|
|
||||||
use crate::math::log2_64;
|
|
||||||
|
|
||||||
use super::objects_split::{median_split, sah_split};
|
use super::objects_split::{median_split, sah_split};
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::bbox::BBox;
|
use crate::{
|
||||||
use crate::math::{Normal, Point, Vector};
|
bbox::BBox,
|
||||||
use crate::shading::surface_closure::SurfaceClosure;
|
math::{Normal, Point, Vector},
|
||||||
|
shading::surface_closure::SurfaceClosure,
|
||||||
|
};
|
||||||
|
|
||||||
use super::LightAccel;
|
use super::LightAccel;
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::algorithm::merge_slices_append;
|
use crate::{
|
||||||
use crate::bbox::BBox;
|
algorithm::merge_slices_append,
|
||||||
use crate::lerp::lerp_slice;
|
bbox::BBox,
|
||||||
use crate::math::{Normal, Point, Vector};
|
lerp::lerp_slice,
|
||||||
use crate::shading::surface_closure::SurfaceClosure;
|
math::{Normal, Point, Vector},
|
||||||
|
shading::surface_closure::SurfaceClosure,
|
||||||
|
};
|
||||||
|
|
||||||
use super::objects_split::sah_split;
|
use super::{objects_split::sah_split, LightAccel};
|
||||||
use super::LightAccel;
|
|
||||||
|
|
||||||
const ARITY_LOG2: usize = 3; // Determines how much to collapse the binary tree,
|
const ARITY_LOG2: usize = 3; // Determines how much to collapse the binary tree,
|
||||||
// implicitly defining the light tree's arity. 1 = no collapsing, leave as binary
|
// implicitly defining the light tree's arity. 1 = no collapsing, leave as binary
|
||||||
|
|
|
@ -7,13 +7,17 @@ mod objects_split;
|
||||||
|
|
||||||
use std::cell::Cell;
|
use std::cell::Cell;
|
||||||
|
|
||||||
use crate::math::{Normal, Point, Vector};
|
use crate::{
|
||||||
use crate::shading::surface_closure::SurfaceClosure;
|
math::{Normal, Point, Vector},
|
||||||
|
shading::surface_closure::SurfaceClosure,
|
||||||
|
};
|
||||||
|
|
||||||
pub use self::bvh::{BVHNode, BVH};
|
pub use self::{
|
||||||
pub use self::bvh4::{BVH4Node, BVH4};
|
bvh::{BVHNode, BVH},
|
||||||
pub use self::light_array::LightArray;
|
bvh4::{BVH4Node, BVH4},
|
||||||
pub use self::light_tree::LightTree;
|
light_array::LightArray,
|
||||||
|
light_tree::LightTree,
|
||||||
|
};
|
||||||
|
|
||||||
// Track BVH traversal time
|
// Track BVH traversal time
|
||||||
thread_local! {
|
thread_local! {
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std;
|
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
|
|
||||||
use halton;
|
use crate::{
|
||||||
|
algorithm::{partition, quick_select},
|
||||||
use crate::algorithm::{partition, quick_select};
|
bbox::BBox,
|
||||||
use crate::bbox::BBox;
|
lerp::lerp_slice,
|
||||||
use crate::lerp::lerp_slice;
|
math::{dot, Vector},
|
||||||
use crate::math::{dot, Vector};
|
sampling::uniform_sample_hemisphere,
|
||||||
use crate::sampling::uniform_sample_hemisphere;
|
};
|
||||||
|
|
||||||
const SAH_BIN_COUNT: usize = 13; // Prime numbers work best, for some reason
|
const SAH_BIN_COUNT: usize = 13; // Prime numbers work best, for some reason
|
||||||
const SPLIT_PLANE_COUNT: usize = 5;
|
const SPLIT_PLANE_COUNT: usize = 5;
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std;
|
use std::cmp::{self, Ordering};
|
||||||
use std::cmp;
|
|
||||||
use std::cmp::Ordering;
|
|
||||||
|
|
||||||
use crate::hash::hash_u64;
|
use crate::{
|
||||||
use crate::lerp::{lerp_slice, Lerp};
|
hash::hash_u64,
|
||||||
|
lerp::{lerp_slice, Lerp},
|
||||||
|
};
|
||||||
|
|
||||||
/// Selects an item from a slice based on a weighting function and a
|
/// Selects an item from a slice based on a weighting function and a
|
||||||
/// number (n) between 0.0 and 1.0. Returns the index of the selected
|
/// number (n) between 0.0 and 1.0. Returns the index of the selected
|
||||||
|
|
15
src/bbox.rs
15
src/bbox.rs
|
@ -1,12 +1,15 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std;
|
use std::{
|
||||||
use std::iter::Iterator;
|
iter::Iterator,
|
||||||
use std::ops::{BitOr, BitOrAssign};
|
ops::{BitOr, BitOrAssign},
|
||||||
|
};
|
||||||
|
|
||||||
use crate::lerp::{lerp, lerp_slice, Lerp};
|
use crate::{
|
||||||
use crate::math::{fast_minf32, Matrix4x4, Point};
|
lerp::{lerp, lerp_slice, Lerp},
|
||||||
use crate::ray::AccelRay;
|
math::{fast_minf32, Matrix4x4, Point},
|
||||||
|
ray::AccelRay,
|
||||||
|
};
|
||||||
|
|
||||||
const BBOX_MAXT_ADJUST: f32 = 1.000_000_24;
|
const BBOX_MAXT_ADJUST: f32 = 1.000_000_24;
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::lerp::lerp_slice;
|
use crate::{
|
||||||
use crate::math::{Matrix4x4, Point, Vector};
|
lerp::lerp_slice,
|
||||||
use crate::ray::Ray;
|
math::{Matrix4x4, Point, Vector},
|
||||||
use crate::sampling::square_to_circle;
|
ray::Ray,
|
||||||
|
sampling::square_to_circle,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct Camera<'a> {
|
pub struct Camera<'a> {
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign};
|
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign};
|
||||||
|
|
||||||
|
pub use color::{rec709_e_to_xyz, rec709_to_xyz, xyz_to_rec709, xyz_to_rec709_e};
|
||||||
|
use float4::Float4;
|
||||||
use spectra_xyz::{spectrum_xyz_to_p_4, EQUAL_ENERGY_REFLECTANCE};
|
use spectra_xyz::{spectrum_xyz_to_p_4, EQUAL_ENERGY_REFLECTANCE};
|
||||||
|
|
||||||
use crate::lerp::Lerp;
|
use crate::{lerp::Lerp, math::fast_exp};
|
||||||
use crate::math::fast_exp;
|
|
||||||
use float4::Float4;
|
|
||||||
|
|
||||||
pub use crate::color_util::{rec709_e_to_xyz, rec709_to_xyz, xyz_to_rec709, xyz_to_rec709_e};
|
|
||||||
|
|
||||||
// Minimum and maximum wavelength of light we care about, in nanometers
|
// Minimum and maximum wavelength of light we care about, in nanometers
|
||||||
const WL_MIN: f32 = 380.0;
|
const WL_MIN: f32 = 380.0;
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use std;
|
|
||||||
|
|
||||||
pub fn hash_u32(n: u32, seed: u32) -> u32 {
|
pub fn hash_u32(n: u32, seed: u32) -> u32 {
|
||||||
let mut hash = n;
|
let mut hash = n;
|
||||||
for _ in 0..3 {
|
for _ in 0..3 {
|
||||||
|
|
20
src/image.rs
20
src/image.rs
|
@ -1,17 +1,17 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std::cell::{RefCell, UnsafeCell};
|
use std::{
|
||||||
use std::cmp;
|
cell::{RefCell, UnsafeCell},
|
||||||
use std::fs::File;
|
cmp,
|
||||||
use std::io;
|
fs::File,
|
||||||
use std::io::Write;
|
io,
|
||||||
use std::marker::PhantomData;
|
io::Write,
|
||||||
use std::path::Path;
|
marker::PhantomData,
|
||||||
use std::sync::Mutex;
|
path::Path,
|
||||||
|
sync::Mutex,
|
||||||
|
};
|
||||||
|
|
||||||
use half::f16;
|
use half::f16;
|
||||||
use openexr;
|
|
||||||
use png_encode_mini;
|
|
||||||
|
|
||||||
use crate::color::{xyz_to_rec709_e, XYZ};
|
use crate::color::{xyz_to_rec709_e, XYZ};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use float4;
|
|
||||||
use math3d::{Matrix4x4, Normal, Point, Vector};
|
use math3d::{Matrix4x4, Normal, Point, Vector};
|
||||||
|
|
||||||
/// Trait for allowing a type to be linearly interpolated.
|
/// Trait for allowing a type to be linearly interpolated.
|
||||||
|
|
|
@ -2,10 +2,12 @@ use std::f64::consts::PI as PI_64;
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::color::{Color, SpectralSample, XYZ};
|
use crate::{
|
||||||
use crate::lerp::lerp_slice;
|
color::{Color, SpectralSample, XYZ},
|
||||||
use crate::math::{coordinate_system_from_vector, Vector};
|
lerp::lerp_slice,
|
||||||
use crate::sampling::{uniform_sample_cone, uniform_sample_cone_pdf};
|
math::{coordinate_system_from_vector, Vector},
|
||||||
|
sampling::{uniform_sample_cone, uniform_sample_cone_pdf},
|
||||||
|
};
|
||||||
|
|
||||||
use super::WorldLightSource;
|
use super::WorldLightSource;
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,16 @@ mod sphere_light;
|
||||||
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
use crate::color::SpectralSample;
|
use crate::{
|
||||||
use crate::math::{Matrix4x4, Normal, Point, Vector};
|
color::SpectralSample,
|
||||||
use crate::surface::Surface;
|
math::{Matrix4x4, Normal, Point, Vector},
|
||||||
|
surface::Surface,
|
||||||
|
};
|
||||||
|
|
||||||
pub use self::distant_disk_light::DistantDiskLight;
|
pub use self::{
|
||||||
pub use self::rectangle_light::RectangleLight;
|
distant_disk_light::DistantDiskLight, rectangle_light::RectangleLight,
|
||||||
pub use self::sphere_light::SphereLight;
|
sphere_light::SphereLight,
|
||||||
|
};
|
||||||
|
|
||||||
/// A finite light source that can be bounded in space.
|
/// A finite light source that can be bounded in space.
|
||||||
pub trait SurfaceLight: Surface {
|
pub trait SurfaceLight: Surface {
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::bbox::BBox;
|
use crate::{
|
||||||
use crate::boundable::Boundable;
|
bbox::BBox,
|
||||||
use crate::color::{Color, SpectralSample, XYZ};
|
boundable::Boundable,
|
||||||
use crate::lerp::lerp_slice;
|
color::{Color, SpectralSample, XYZ},
|
||||||
use crate::math::{cross, dot, Matrix4x4, Normal, Point, Vector};
|
lerp::lerp_slice,
|
||||||
use crate::ray::{AccelRay, Ray};
|
math::{cross, dot, Matrix4x4, Normal, Point, Vector},
|
||||||
use crate::sampling::{
|
ray::{AccelRay, Ray},
|
||||||
spherical_triangle_solid_angle, triangle_surface_area, uniform_sample_spherical_triangle,
|
sampling::{
|
||||||
uniform_sample_triangle,
|
spherical_triangle_solid_angle, triangle_surface_area, uniform_sample_spherical_triangle,
|
||||||
|
uniform_sample_triangle,
|
||||||
|
},
|
||||||
|
shading::surface_closure::{EmitClosure, SurfaceClosureUnion},
|
||||||
|
shading::SurfaceShader,
|
||||||
|
surface::{triangle, Surface, SurfaceIntersection, SurfaceIntersectionData},
|
||||||
};
|
};
|
||||||
use crate::shading::surface_closure::{EmitClosure, SurfaceClosureUnion};
|
|
||||||
use crate::shading::SurfaceShader;
|
|
||||||
use crate::surface::{triangle, Surface, SurfaceIntersection, SurfaceIntersectionData};
|
|
||||||
|
|
||||||
use super::SurfaceLight;
|
use super::SurfaceLight;
|
||||||
|
|
||||||
|
|
|
@ -2,16 +2,18 @@ use std::f64::consts::PI as PI_64;
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::bbox::BBox;
|
use crate::{
|
||||||
use crate::boundable::Boundable;
|
bbox::BBox,
|
||||||
use crate::color::{Color, SpectralSample, XYZ};
|
boundable::Boundable,
|
||||||
use crate::lerp::lerp_slice;
|
color::{Color, SpectralSample, XYZ},
|
||||||
use crate::math::{coordinate_system_from_vector, dot, Matrix4x4, Normal, Point, Vector};
|
lerp::lerp_slice,
|
||||||
use crate::ray::{AccelRay, Ray};
|
math::{coordinate_system_from_vector, dot, Matrix4x4, Normal, Point, Vector},
|
||||||
use crate::sampling::{uniform_sample_cone, uniform_sample_cone_pdf, uniform_sample_sphere};
|
ray::{AccelRay, Ray},
|
||||||
use crate::shading::surface_closure::{EmitClosure, SurfaceClosureUnion};
|
sampling::{uniform_sample_cone, uniform_sample_cone_pdf, uniform_sample_sphere},
|
||||||
use crate::shading::SurfaceShader;
|
shading::surface_closure::{EmitClosure, SurfaceClosureUnion},
|
||||||
use crate::surface::{Surface, SurfaceIntersection, SurfaceIntersectionData};
|
shading::SurfaceShader,
|
||||||
|
surface::{Surface, SurfaceIntersection, SurfaceIntersectionData},
|
||||||
|
};
|
||||||
|
|
||||||
use super::SurfaceLight;
|
use super::SurfaceLight;
|
||||||
|
|
||||||
|
|
46
src/main.rs
46
src/main.rs
|
@ -11,28 +11,6 @@
|
||||||
#![allow(clippy::needless_range_loop)]
|
#![allow(clippy::needless_range_loop)]
|
||||||
#![allow(clippy::excessive_precision)]
|
#![allow(clippy::excessive_precision)]
|
||||||
|
|
||||||
extern crate bvh_order;
|
|
||||||
extern crate color as color_util;
|
|
||||||
extern crate float4;
|
|
||||||
extern crate halton;
|
|
||||||
extern crate math3d;
|
|
||||||
extern crate mem_arena;
|
|
||||||
extern crate spectra_xyz;
|
|
||||||
|
|
||||||
extern crate base64;
|
|
||||||
extern crate clap;
|
|
||||||
extern crate crossbeam;
|
|
||||||
extern crate half;
|
|
||||||
extern crate num_cpus;
|
|
||||||
extern crate openexr;
|
|
||||||
extern crate png_encode_mini;
|
|
||||||
extern crate rustc_serialize;
|
|
||||||
extern crate scoped_threadpool;
|
|
||||||
extern crate time;
|
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate nom;
|
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
|
@ -61,24 +39,22 @@ mod timer;
|
||||||
mod tracer;
|
mod tracer;
|
||||||
mod transform_stack;
|
mod transform_stack;
|
||||||
|
|
||||||
use std::fs::File;
|
use std::{fs::File, io, io::Read, mem, path::Path, str::FromStr};
|
||||||
use std::io;
|
|
||||||
use std::io::Read;
|
|
||||||
use std::mem;
|
|
||||||
use std::path::Path;
|
|
||||||
use std::str::FromStr;
|
|
||||||
|
|
||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
|
use nom::{error_position, take_until};
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::accel::{BVH4Node, BVHNode};
|
use crate::{
|
||||||
use crate::bbox::BBox;
|
accel::{BVH4Node, BVHNode},
|
||||||
use crate::parse::{parse_scene, DataTree};
|
bbox::BBox,
|
||||||
use crate::ray::{AccelRay, Ray};
|
parse::{parse_scene, DataTree},
|
||||||
use crate::renderer::LightPath;
|
ray::{AccelRay, Ray},
|
||||||
use crate::surface::SurfaceIntersection;
|
renderer::LightPath,
|
||||||
use crate::timer::Timer;
|
surface::SurfaceIntersection,
|
||||||
|
timer::Timer,
|
||||||
|
};
|
||||||
|
|
||||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,12 @@
|
||||||
|
|
||||||
use std::str;
|
use std::str;
|
||||||
|
|
||||||
use nom::IResult::*;
|
use nom::{
|
||||||
use nom::{digit, multispace, IResult, Needed};
|
call, complete, delimited, digit, do_parse, error_position, multispace, named, one_of, opt,
|
||||||
|
tag, tuple_parser,
|
||||||
|
IResult::{self, *},
|
||||||
|
Needed,
|
||||||
|
};
|
||||||
|
|
||||||
// Consumes any whitespace, including zero whitespace
|
// Consumes any whitespace, including zero whitespace
|
||||||
named!(any_space<Option<&[u8]>>, opt!(complete!(multispace)));
|
named!(any_space<Option<&[u8]>>, opt!(complete!(multispace)));
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std::iter::Iterator;
|
use std::{iter::Iterator, result::Result, slice};
|
||||||
use std::result::Result;
|
|
||||||
use std::slice;
|
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialEq)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub enum DataTree<'a> {
|
pub enum DataTree<'a> {
|
||||||
|
|
|
@ -6,5 +6,4 @@ mod psy_light;
|
||||||
mod psy_mesh_surface;
|
mod psy_mesh_surface;
|
||||||
mod psy_surface_shader;
|
mod psy_surface_shader;
|
||||||
|
|
||||||
pub use self::data_tree::DataTree;
|
pub use self::{data_tree::DataTree, psy::parse_scene};
|
||||||
pub use self::psy::parse_scene;
|
|
||||||
|
|
|
@ -1,24 +1,27 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std::f32;
|
use std::{f32, result::Result};
|
||||||
use std::result::Result;
|
|
||||||
|
|
||||||
use nom::IResult;
|
use nom::{call, closure, eof, error_position, terminated, tuple, tuple_parser, IResult};
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::camera::Camera;
|
use crate::{
|
||||||
use crate::color::{rec709_e_to_xyz, XYZ};
|
camera::Camera,
|
||||||
use crate::light::WorldLightSource;
|
color::{rec709_e_to_xyz, XYZ},
|
||||||
use crate::math::Matrix4x4;
|
light::WorldLightSource,
|
||||||
use crate::renderer::Renderer;
|
math::Matrix4x4,
|
||||||
use crate::scene::Scene;
|
renderer::Renderer,
|
||||||
use crate::scene::World;
|
scene::Scene,
|
||||||
|
scene::World,
|
||||||
|
};
|
||||||
|
|
||||||
use super::basics::{ws_f32, ws_u32};
|
use super::{
|
||||||
use super::psy_assembly::parse_assembly;
|
basics::{ws_f32, ws_u32},
|
||||||
use super::psy_light::parse_distant_disk_light;
|
psy_assembly::parse_assembly,
|
||||||
use super::DataTree;
|
psy_light::parse_distant_disk_light,
|
||||||
|
DataTree,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum PsyParseError {
|
pub enum PsyParseError {
|
||||||
|
|
|
@ -6,11 +6,13 @@ use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::scene::{Assembly, AssemblyBuilder, Object};
|
use crate::scene::{Assembly, AssemblyBuilder, Object};
|
||||||
|
|
||||||
use super::psy::{parse_matrix, PsyParseError};
|
use super::{
|
||||||
use super::psy_light::{parse_rectangle_light, parse_sphere_light};
|
psy::{parse_matrix, PsyParseError},
|
||||||
use super::psy_mesh_surface::parse_mesh_surface;
|
psy_light::{parse_rectangle_light, parse_sphere_light},
|
||||||
use super::psy_surface_shader::parse_surface_shader;
|
psy_mesh_surface::parse_mesh_surface,
|
||||||
use super::DataTree;
|
psy_surface_shader::parse_surface_shader,
|
||||||
|
DataTree,
|
||||||
|
};
|
||||||
|
|
||||||
pub fn parse_assembly<'a>(
|
pub fn parse_assembly<'a>(
|
||||||
arena: &'a MemArena,
|
arena: &'a MemArena,
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
|
|
||||||
use std::result::Result;
|
use std::result::Result;
|
||||||
|
|
||||||
use nom::IResult;
|
use nom::{call, closure, tuple, tuple_parser, IResult};
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::color::{rec709_e_to_xyz, XYZ};
|
use crate::{
|
||||||
use crate::light::{DistantDiskLight, RectangleLight, SphereLight};
|
color::{rec709_e_to_xyz, XYZ},
|
||||||
use crate::math::Vector;
|
light::{DistantDiskLight, RectangleLight, SphereLight},
|
||||||
|
math::Vector,
|
||||||
|
};
|
||||||
|
|
||||||
use super::basics::ws_f32;
|
use super::{basics::ws_f32, psy::PsyParseError, DataTree};
|
||||||
use super::psy::PsyParseError;
|
|
||||||
use super::DataTree;
|
|
||||||
|
|
||||||
pub fn parse_distant_disk_light<'a>(
|
pub fn parse_distant_disk_light<'a>(
|
||||||
arena: &'a MemArena,
|
arena: &'a MemArena,
|
||||||
|
|
|
@ -2,16 +2,20 @@
|
||||||
|
|
||||||
use std::result::Result;
|
use std::result::Result;
|
||||||
|
|
||||||
use nom::IResult;
|
use nom::{call, closure, tuple, tuple_parser, IResult};
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::math::{Normal, Point};
|
use crate::{
|
||||||
use crate::surface::triangle_mesh::TriangleMesh;
|
math::{Normal, Point},
|
||||||
|
surface::triangle_mesh::TriangleMesh,
|
||||||
|
};
|
||||||
|
|
||||||
use super::basics::{ws_f32, ws_usize};
|
use super::{
|
||||||
use super::psy::PsyParseError;
|
basics::{ws_f32, ws_usize},
|
||||||
use super::DataTree;
|
psy::PsyParseError,
|
||||||
|
DataTree,
|
||||||
|
};
|
||||||
|
|
||||||
// pub struct TriangleMesh {
|
// pub struct TriangleMesh {
|
||||||
// time_samples: usize,
|
// time_samples: usize,
|
||||||
|
|
|
@ -2,16 +2,16 @@
|
||||||
|
|
||||||
use std::result::Result;
|
use std::result::Result;
|
||||||
|
|
||||||
use nom::IResult;
|
use nom::{call, closure, tuple, tuple_parser, IResult};
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::color::{rec709_e_to_xyz, XYZ};
|
use crate::{
|
||||||
use crate::shading::{SimpleSurfaceShader, SurfaceShader};
|
color::{rec709_e_to_xyz, XYZ},
|
||||||
|
shading::{SimpleSurfaceShader, SurfaceShader},
|
||||||
|
};
|
||||||
|
|
||||||
use super::basics::ws_f32;
|
use super::{basics::ws_f32, psy::PsyParseError, DataTree};
|
||||||
use super::psy::PsyParseError;
|
|
||||||
use super::DataTree;
|
|
||||||
|
|
||||||
// pub struct TriangleMesh {
|
// pub struct TriangleMesh {
|
||||||
// time_samples: usize,
|
// time_samples: usize,
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std;
|
use float4::Float4;
|
||||||
|
|
||||||
use crate::math::{Matrix4x4, Point, Vector};
|
use crate::math::{Matrix4x4, Point, Vector};
|
||||||
use float4::Float4;
|
|
||||||
|
|
||||||
const OCCLUSION_FLAG: u32 = 1;
|
const OCCLUSION_FLAG: u32 = 1;
|
||||||
const DONE_FLAG: u32 = 1 << 1;
|
const DONE_FLAG: u32 = 1 << 1;
|
||||||
|
|
|
@ -1,32 +1,34 @@
|
||||||
use std;
|
use std::{
|
||||||
use std::cell::Cell;
|
cell::Cell,
|
||||||
use std::cmp;
|
cmp,
|
||||||
use std::cmp::min;
|
cmp::min,
|
||||||
use std::io::{self, Write};
|
io::{self, Write},
|
||||||
use std::sync::{Mutex, RwLock};
|
sync::{Mutex, RwLock},
|
||||||
|
};
|
||||||
|
|
||||||
use crossbeam::sync::MsQueue;
|
use crossbeam::sync::MsQueue;
|
||||||
use scoped_threadpool::Pool;
|
use scoped_threadpool::Pool;
|
||||||
|
|
||||||
use halton;
|
|
||||||
|
|
||||||
use crate::accel::{ACCEL_NODE_RAY_TESTS, ACCEL_TRAV_TIME};
|
|
||||||
use crate::algorithm::partition_pair;
|
|
||||||
use crate::color::{map_0_1_to_wavelength, Color, SpectralSample, XYZ};
|
|
||||||
use crate::fp_utils::robust_ray_origin;
|
|
||||||
use crate::hash::hash_u32;
|
|
||||||
use crate::hilbert;
|
|
||||||
use crate::image::Image;
|
|
||||||
use crate::math::{fast_logit, upper_power_of_two};
|
|
||||||
use crate::mis::power_heuristic;
|
|
||||||
use crate::ray::Ray;
|
|
||||||
use crate::scene::{Scene, SceneLightSample};
|
|
||||||
use crate::surface;
|
|
||||||
use crate::timer::Timer;
|
|
||||||
use crate::tracer::Tracer;
|
|
||||||
use crate::transform_stack::TransformStack;
|
|
||||||
use float4::Float4;
|
use float4::Float4;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
accel::{ACCEL_NODE_RAY_TESTS, ACCEL_TRAV_TIME},
|
||||||
|
algorithm::partition_pair,
|
||||||
|
color::{map_0_1_to_wavelength, Color, SpectralSample, XYZ},
|
||||||
|
fp_utils::robust_ray_origin,
|
||||||
|
hash::hash_u32,
|
||||||
|
hilbert,
|
||||||
|
image::Image,
|
||||||
|
math::{fast_logit, upper_power_of_two},
|
||||||
|
mis::power_heuristic,
|
||||||
|
ray::Ray,
|
||||||
|
scene::{Scene, SceneLightSample},
|
||||||
|
surface,
|
||||||
|
timer::Timer,
|
||||||
|
tracer::Tracer,
|
||||||
|
transform_stack::TransformStack,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Renderer<'a> {
|
pub struct Renderer<'a> {
|
||||||
pub output_file: String,
|
pub output_file: String,
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std::f32::consts::FRAC_PI_4 as QPI_32;
|
use std::{f32::consts::FRAC_PI_4 as QPI_32, f32::consts::PI as PI_32, f64::consts::PI as PI_64};
|
||||||
use std::f32::consts::PI as PI_32;
|
|
||||||
use std::f64::consts::PI as PI_64;
|
|
||||||
|
|
||||||
use crate::math::{cross, dot, Point, Vector};
|
use crate::math::{cross, dot, Point, Vector};
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,19 @@ use std::collections::HashMap;
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::accel::BVH4;
|
use crate::{
|
||||||
use crate::accel::{LightAccel, LightTree};
|
accel::BVH4,
|
||||||
use crate::bbox::{transform_bbox_slice_from, BBox};
|
accel::{LightAccel, LightTree},
|
||||||
use crate::boundable::Boundable;
|
bbox::{transform_bbox_slice_from, BBox},
|
||||||
use crate::color::SpectralSample;
|
boundable::Boundable,
|
||||||
use crate::lerp::lerp_slice;
|
color::SpectralSample,
|
||||||
use crate::light::SurfaceLight;
|
lerp::lerp_slice,
|
||||||
use crate::math::{Matrix4x4, Normal, Point};
|
light::SurfaceLight,
|
||||||
use crate::shading::SurfaceShader;
|
math::{Matrix4x4, Normal, Point},
|
||||||
use crate::surface::{Surface, SurfaceIntersection};
|
shading::SurfaceShader,
|
||||||
use crate::transform_stack::TransformStack;
|
surface::{Surface, SurfaceIntersection},
|
||||||
|
transform_stack::TransformStack,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct Assembly<'a> {
|
pub struct Assembly<'a> {
|
||||||
|
|
|
@ -1,16 +1,20 @@
|
||||||
mod assembly;
|
mod assembly;
|
||||||
mod world;
|
mod world;
|
||||||
|
|
||||||
use crate::accel::LightAccel;
|
use crate::{
|
||||||
use crate::algorithm::weighted_choice;
|
accel::LightAccel,
|
||||||
use crate::camera::Camera;
|
algorithm::weighted_choice,
|
||||||
use crate::color::SpectralSample;
|
camera::Camera,
|
||||||
use crate::math::{Normal, Point, Vector};
|
color::SpectralSample,
|
||||||
use crate::surface::SurfaceIntersection;
|
math::{Normal, Point, Vector},
|
||||||
use crate::transform_stack::TransformStack;
|
surface::SurfaceIntersection,
|
||||||
|
transform_stack::TransformStack,
|
||||||
|
};
|
||||||
|
|
||||||
pub use self::assembly::{Assembly, AssemblyBuilder, InstanceType, Object};
|
pub use self::{
|
||||||
pub use self::world::World;
|
assembly::{Assembly, AssemblyBuilder, InstanceType, Object},
|
||||||
|
world::World,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Scene<'a> {
|
pub struct Scene<'a> {
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::color::XYZ;
|
use crate::{color::XYZ, light::WorldLightSource};
|
||||||
use crate::light::WorldLightSource;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct World<'a> {
|
pub struct World<'a> {
|
||||||
|
|
|
@ -2,11 +2,14 @@ pub mod surface_closure;
|
||||||
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
|
use crate::{
|
||||||
|
color::{Color, XYZ},
|
||||||
|
surface::SurfaceIntersectionData,
|
||||||
|
};
|
||||||
|
|
||||||
use self::surface_closure::{
|
use self::surface_closure::{
|
||||||
EmitClosure, GGXClosure, GTRClosure, LambertClosure, SurfaceClosureUnion,
|
EmitClosure, GGXClosure, GTRClosure, LambertClosure, SurfaceClosureUnion,
|
||||||
};
|
};
|
||||||
use crate::color::{Color, XYZ};
|
|
||||||
use crate::surface::SurfaceIntersectionData;
|
|
||||||
|
|
||||||
/// Trait for surface shaders.
|
/// Trait for surface shaders.
|
||||||
pub trait SurfaceShader: Debug + Sync {
|
pub trait SurfaceShader: Debug + Sync {
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
use std::f32::consts::PI as PI_32;
|
use std::f32::consts::PI as PI_32;
|
||||||
|
|
||||||
use crate::color::SpectralSample;
|
use crate::{
|
||||||
use crate::lerp::lerp;
|
color::SpectralSample,
|
||||||
use crate::math::{clamp, dot, zup_to_vec, Normal, Vector};
|
lerp::lerp,
|
||||||
use crate::sampling::cosine_sample_hemisphere;
|
math::{clamp, dot, zup_to_vec, Normal, Vector},
|
||||||
|
sampling::cosine_sample_hemisphere,
|
||||||
|
};
|
||||||
|
|
||||||
const INV_PI: f32 = 1.0 / PI_32;
|
const INV_PI: f32 = 1.0 / PI_32;
|
||||||
const H_PI: f32 = PI_32 / 2.0;
|
const H_PI: f32 = PI_32 / 2.0;
|
||||||
|
|
|
@ -5,11 +5,13 @@ pub mod triangle_mesh;
|
||||||
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
use crate::boundable::Boundable;
|
use crate::{
|
||||||
use crate::math::{Matrix4x4, Normal, Point, Vector};
|
boundable::Boundable,
|
||||||
use crate::ray::{AccelRay, Ray};
|
math::{Matrix4x4, Normal, Point, Vector},
|
||||||
use crate::shading::surface_closure::SurfaceClosureUnion;
|
ray::{AccelRay, Ray},
|
||||||
use crate::shading::SurfaceShader;
|
shading::surface_closure::SurfaceClosureUnion,
|
||||||
|
shading::SurfaceShader,
|
||||||
|
};
|
||||||
|
|
||||||
pub trait Surface: Boundable + Debug + Sync {
|
pub trait Surface: Boundable + Debug + Sync {
|
||||||
fn intersect_rays(
|
fn intersect_rays(
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use crate::fp_utils::fp_gamma;
|
use crate::{fp_utils::fp_gamma, math::Point, ray::Ray};
|
||||||
use crate::math::Point;
|
|
||||||
use crate::ray::Ray;
|
|
||||||
|
|
||||||
/// Intersects `ray` with `tri`, returning `Some((t, b0, b1, b2))`, or `None`
|
/// Intersects `ray` with `tri`, returning `Some((t, b0, b1, b2))`, or `None`
|
||||||
/// if no intersection.
|
/// if no intersection.
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std;
|
|
||||||
|
|
||||||
use mem_arena::MemArena;
|
use mem_arena::MemArena;
|
||||||
|
|
||||||
use crate::accel::BVH4;
|
use crate::{
|
||||||
use crate::bbox::BBox;
|
accel::BVH4,
|
||||||
use crate::boundable::Boundable;
|
bbox::BBox,
|
||||||
use crate::lerp::lerp_slice;
|
boundable::Boundable,
|
||||||
use crate::math::{cross, dot, Matrix4x4, Normal, Point};
|
lerp::lerp_slice,
|
||||||
use crate::ray::{AccelRay, Ray};
|
math::{cross, dot, Matrix4x4, Normal, Point},
|
||||||
use crate::shading::SurfaceShader;
|
ray::{AccelRay, Ray},
|
||||||
|
shading::SurfaceShader,
|
||||||
|
};
|
||||||
|
|
||||||
use super::triangle;
|
use super::{triangle, Surface, SurfaceIntersection, SurfaceIntersectionData};
|
||||||
use super::{Surface, SurfaceIntersection, SurfaceIntersectionData};
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
pub struct TriangleMesh<'a> {
|
pub struct TriangleMesh<'a> {
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
use std::thread;
|
use std::{thread, time::Duration};
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
use time;
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct Timer {
|
pub struct Timer {
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
use std::iter;
|
use std::iter;
|
||||||
|
|
||||||
use crate::algorithm::partition;
|
use crate::{
|
||||||
use crate::color::{rec709_to_xyz, XYZ};
|
algorithm::partition,
|
||||||
use crate::lerp::lerp_slice;
|
color::{rec709_to_xyz, XYZ},
|
||||||
use crate::ray::{AccelRay, Ray};
|
lerp::lerp_slice,
|
||||||
use crate::scene::{Assembly, InstanceType, Object};
|
ray::{AccelRay, Ray},
|
||||||
use crate::shading::{SimpleSurfaceShader, SurfaceShader};
|
scene::{Assembly, InstanceType, Object},
|
||||||
use crate::surface::SurfaceIntersection;
|
shading::{SimpleSurfaceShader, SurfaceShader},
|
||||||
use crate::transform_stack::TransformStack;
|
surface::SurfaceIntersection,
|
||||||
|
transform_stack::TransformStack,
|
||||||
|
};
|
||||||
|
|
||||||
pub struct Tracer<'a> {
|
pub struct Tracer<'a> {
|
||||||
rays: Vec<AccelRay>,
|
rays: Vec<AccelRay>,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use std::cmp;
|
use std::cmp;
|
||||||
|
|
||||||
use crate::algorithm::merge_slices_to;
|
use crate::{algorithm::merge_slices_to, math::Matrix4x4};
|
||||||
use crate::math::Matrix4x4;
|
|
||||||
|
|
||||||
pub struct TransformStack {
|
pub struct TransformStack {
|
||||||
stack: Vec<Matrix4x4>,
|
stack: Vec<Matrix4x4>,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user