Run latest rustfmt. No functional changes.
This commit is contained in:
parent
caeb1d9c67
commit
c002514ddf
|
@ -119,10 +119,12 @@ impl BVHBase {
|
||||||
// We make sure that it's worth having multiple time samples, and if not
|
// We make sure that it's worth having multiple time samples, and if not
|
||||||
// we reduce to the union of the time samples.
|
// we reduce to the union of the time samples.
|
||||||
self.acc_bounds(objects, bounder);
|
self.acc_bounds(objects, bounder);
|
||||||
let union_bounds = self.bounds_cache
|
let union_bounds = self
|
||||||
|
.bounds_cache
|
||||||
.iter()
|
.iter()
|
||||||
.fold(BBox::new(), |b1, b2| (b1 | *b2));
|
.fold(BBox::new(), |b1, b2| (b1 | *b2));
|
||||||
let average_area = self.bounds_cache
|
let average_area = self
|
||||||
|
.bounds_cache
|
||||||
.iter()
|
.iter()
|
||||||
.fold(0.0, |area, bb| area + bb.surface_area())
|
.fold(0.0, |area, bb| area + bb.surface_area())
|
||||||
/ self.bounds_cache.len() as f32;
|
/ self.bounds_cache.len() as f32;
|
||||||
|
|
|
@ -55,7 +55,8 @@ impl<'a> Camera<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert angle fov into linear fov.
|
// Convert angle fov into linear fov.
|
||||||
let tfovs: Vec<f32> = fovs.iter()
|
let tfovs: Vec<f32> = fovs
|
||||||
|
.iter()
|
||||||
.map(|n| (n / 2.0).sin() / (n / 2.0).cos())
|
.map(|n| (n / 2.0).sin() / (n / 2.0).cos())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,8 @@ impl<'a> WorldLightSource for DistantDiskLight<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn approximate_energy(&self) -> f32 {
|
fn approximate_energy(&self) -> f32 {
|
||||||
let color: XYZ = self.colors
|
let color: XYZ = self
|
||||||
|
.colors
|
||||||
.iter()
|
.iter()
|
||||||
.fold(XYZ::new(0.0, 0.0, 0.0), |a, &b| a + b)
|
.fold(XYZ::new(0.0, 0.0, 0.0), |a, &b| a + b)
|
||||||
/ self.colors.len() as f32;
|
/ self.colors.len() as f32;
|
||||||
|
|
|
@ -244,7 +244,8 @@ impl<'a> SurfaceLight for RectangleLight<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn approximate_energy(&self) -> f32 {
|
fn approximate_energy(&self) -> f32 {
|
||||||
let color: XYZ = self.colors
|
let color: XYZ = self
|
||||||
|
.colors
|
||||||
.iter()
|
.iter()
|
||||||
.fold(XYZ::new(0.0, 0.0, 0.0), |a, &b| a + b)
|
.fold(XYZ::new(0.0, 0.0, 0.0), |a, &b| a + b)
|
||||||
/ self.colors.len() as f32;
|
/ self.colors.len() as f32;
|
||||||
|
|
|
@ -194,7 +194,8 @@ impl<'a> SurfaceLight for SphereLight<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn approximate_energy(&self) -> f32 {
|
fn approximate_energy(&self) -> f32 {
|
||||||
let color: XYZ = self.colors
|
let color: XYZ = self
|
||||||
|
.colors
|
||||||
.iter()
|
.iter()
|
||||||
.fold(XYZ::new(0.0, 0.0, 0.0), |a, &b| a + b)
|
.fold(XYZ::new(0.0, 0.0, 0.0), |a, &b| a + b)
|
||||||
/ self.colors.len() as f32;
|
/ self.colors.len() as f32;
|
||||||
|
|
|
@ -244,7 +244,8 @@ impl<'a> AssemblyBuilder<'a> {
|
||||||
instance_type: InstanceType::Object,
|
instance_type: InstanceType::Object,
|
||||||
data_index: self.object_map[name],
|
data_index: self.object_map[name],
|
||||||
surface_shader_index: surface_shader_name.map(|name| {
|
surface_shader_index: surface_shader_name.map(|name| {
|
||||||
*self.surface_shader_map
|
*self
|
||||||
|
.surface_shader_map
|
||||||
.get(name)
|
.get(name)
|
||||||
.expect(&format!("Unknown surface shader '{}'.", name))
|
.expect(&format!("Unknown surface shader '{}'.", name))
|
||||||
}),
|
}),
|
||||||
|
@ -257,7 +258,8 @@ impl<'a> AssemblyBuilder<'a> {
|
||||||
instance_type: InstanceType::Assembly,
|
instance_type: InstanceType::Assembly,
|
||||||
data_index: self.assembly_map[name],
|
data_index: self.assembly_map[name],
|
||||||
surface_shader_index: surface_shader_name.map(|name| {
|
surface_shader_index: surface_shader_name.map(|name| {
|
||||||
*self.surface_shader_map
|
*self
|
||||||
|
.surface_shader_map
|
||||||
.get(name)
|
.get(name)
|
||||||
.expect(&format!("Unknown surface shader '{}'.", name))
|
.expect(&format!("Unknown surface shader '{}'.", name))
|
||||||
}),
|
}),
|
||||||
|
@ -290,7 +292,8 @@ impl<'a> AssemblyBuilder<'a> {
|
||||||
|
|
||||||
// Get list of instances that are for light sources or assemblies that contain light
|
// Get list of instances that are for light sources or assemblies that contain light
|
||||||
// sources.
|
// sources.
|
||||||
let mut light_instances: Vec<_> = self.instances
|
let mut light_instances: Vec<_> = self
|
||||||
|
.instances
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|inst| match inst.instance_type {
|
.filter(|inst| match inst.instance_type {
|
||||||
InstanceType::Object => {
|
InstanceType::Object => {
|
||||||
|
|
|
@ -34,7 +34,8 @@ impl<'a> Scene<'a> {
|
||||||
|
|
||||||
// Calculate relative probabilities of traversing into world lights
|
// Calculate relative probabilities of traversing into world lights
|
||||||
// or local lights.
|
// or local lights.
|
||||||
let wl_energy = if self.world
|
let wl_energy = if self
|
||||||
|
.world
|
||||||
.lights
|
.lights
|
||||||
.iter()
|
.iter()
|
||||||
.fold(0.0, |energy, light| energy + light.approximate_energy())
|
.fold(0.0, |energy, light| energy + light.approximate_energy())
|
||||||
|
|
|
@ -2,7 +2,9 @@ pub mod surface_closure;
|
||||||
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
|
||||||
use self::surface_closure::{EmitClosure, GGXClosure, GTRClosure, LambertClosure, SurfaceClosureUnion};
|
use self::surface_closure::{
|
||||||
|
EmitClosure, GGXClosure, GTRClosure, LambertClosure, SurfaceClosureUnion,
|
||||||
|
};
|
||||||
use color::{Color, XYZ};
|
use color::{Color, XYZ};
|
||||||
use surface::SurfaceIntersectionData;
|
use surface::SurfaceIntersectionData;
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,13 @@ pub trait SurfaceClosure {
|
||||||
///
|
///
|
||||||
/// Returns the resulting filter color and pdf of if this had been generated
|
/// Returns the resulting filter color and pdf of if this had been generated
|
||||||
/// by `sample()`.
|
/// by `sample()`.
|
||||||
fn evaluate(&self, inc: Vector, out: Vector, nor: Normal, nor_g: Normal) -> (SpectralSample, f32);
|
fn evaluate(
|
||||||
|
&self,
|
||||||
|
inc: Vector,
|
||||||
|
out: Vector,
|
||||||
|
nor: Normal,
|
||||||
|
nor_g: Normal,
|
||||||
|
) -> (SpectralSample, f32);
|
||||||
|
|
||||||
/// Returns an estimate of the sum total energy that evaluate() would return
|
/// Returns an estimate of the sum total energy that evaluate() would return
|
||||||
/// when integrated over a spherical light source with a center at relative
|
/// when integrated over a spherical light source with a center at relative
|
||||||
|
@ -191,7 +197,13 @@ impl SurfaceClosure for EmitClosure {
|
||||||
(Vector::new(0.0, 0.0, 0.0), self.col, 1.0)
|
(Vector::new(0.0, 0.0, 0.0), self.col, 1.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn evaluate(&self, inc: Vector, out: Vector, nor: Normal, nor_g: Normal) -> (SpectralSample, f32) {
|
fn evaluate(
|
||||||
|
&self,
|
||||||
|
inc: Vector,
|
||||||
|
out: Vector,
|
||||||
|
nor: Normal,
|
||||||
|
nor_g: Normal,
|
||||||
|
) -> (SpectralSample, f32) {
|
||||||
let _ = (inc, out, nor, nor_g); // Not using these, silence warning
|
let _ = (inc, out, nor, nor_g); // Not using these, silence warning
|
||||||
|
|
||||||
(self.col, 1.0)
|
(self.col, 1.0)
|
||||||
|
@ -257,7 +269,13 @@ impl SurfaceClosure for LambertClosure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn evaluate(&self, inc: Vector, out: Vector, nor: Normal, nor_g: Normal) -> (SpectralSample, f32) {
|
fn evaluate(
|
||||||
|
&self,
|
||||||
|
inc: Vector,
|
||||||
|
out: Vector,
|
||||||
|
nor: Normal,
|
||||||
|
nor_g: Normal,
|
||||||
|
) -> (SpectralSample, f32) {
|
||||||
let (nn, flipped_nor_g) = if dot(nor_g.into_vector(), inc) <= 0.0 {
|
let (nn, flipped_nor_g) = if dot(nor_g.into_vector(), inc) <= 0.0 {
|
||||||
(nor.normalized().into_vector(), nor_g.into_vector())
|
(nor.normalized().into_vector(), nor_g.into_vector())
|
||||||
} else {
|
} else {
|
||||||
|
@ -481,7 +499,13 @@ impl SurfaceClosure for GTRClosure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn evaluate(&self, inc: Vector, out: Vector, nor: Normal, nor_g: Normal) -> (SpectralSample, f32) {
|
fn evaluate(
|
||||||
|
&self,
|
||||||
|
inc: Vector,
|
||||||
|
out: Vector,
|
||||||
|
nor: Normal,
|
||||||
|
nor_g: Normal,
|
||||||
|
) -> (SpectralSample, f32) {
|
||||||
// Calculate needed vectors, normalized
|
// Calculate needed vectors, normalized
|
||||||
let aa = -inc.normalized(); // Vector pointing to where "in" came from
|
let aa = -inc.normalized(); // Vector pointing to where "in" came from
|
||||||
let bb = out.normalized(); // Out
|
let bb = out.normalized(); // Out
|
||||||
|
@ -634,7 +658,6 @@ impl SurfaceClosure for GTRClosure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// The GGX microfacet BRDF.
|
/// The GGX microfacet BRDF.
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone)]
|
||||||
pub struct GGXClosure {
|
pub struct GGXClosure {
|
||||||
|
@ -740,7 +763,13 @@ impl SurfaceClosure for GGXClosure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn evaluate(&self, inc: Vector, out: Vector, nor: Normal, nor_g: Normal) -> (SpectralSample, f32) {
|
fn evaluate(
|
||||||
|
&self,
|
||||||
|
inc: Vector,
|
||||||
|
out: Vector,
|
||||||
|
nor: Normal,
|
||||||
|
nor_g: Normal,
|
||||||
|
) -> (SpectralSample, f32) {
|
||||||
// Calculate needed vectors, normalized
|
// Calculate needed vectors, normalized
|
||||||
let aa = -inc.normalized(); // Vector pointing to where "in" came from
|
let aa = -inc.normalized(); // Vector pointing to where "in" came from
|
||||||
let bb = out.normalized(); // Out
|
let bb = out.normalized(); // Out
|
||||||
|
@ -872,4 +901,4 @@ impl SurfaceClosure for GGXClosure {
|
||||||
|
|
||||||
fac * (1.0f32).min(1.0 - cos_theta_max) * INV_PI
|
fac * (1.0f32).min(1.0 - cos_theta_max) * INV_PI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user