Minor cleanup and tidying; no change in functionality.

This commit is contained in:
Matthew Gordon 2019-12-07 10:24:38 -05:00
parent 2b3d350fbb
commit d98144ab74
4 changed files with 14 additions and 14 deletions

View File

@ -13,8 +13,8 @@ pub struct ImageRgbU8 {
impl ImageRgbU8 { impl ImageRgbU8 {
pub fn new(width: u32, height: u32) -> ImageRgbU8 { pub fn new(width: u32, height: u32) -> ImageRgbU8 {
ImageRgbU8 { ImageRgbU8 {
width: width, width,
height: height, height,
pixel_data: vec![0; (width * height * 3) as usize], pixel_data: vec![0; (width * height * 3) as usize],
} }
} }
@ -73,8 +73,8 @@ pub struct ImageRgbF<T: RealField> {
impl<T: RealField> ImageRgbF<T> { impl<T: RealField> ImageRgbF<T> {
pub fn new(width: u32, height: u32) -> ImageRgbF<T> { pub fn new(width: u32, height: u32) -> ImageRgbF<T> {
ImageRgbF { ImageRgbF {
width: width, width,
height: height, height,
pixel_data: vec![convert(0.0); (width * height * 3) as usize], pixel_data: vec![convert(0.0); (width * height * 3) as usize],
} }
} }

View File

@ -33,7 +33,7 @@ impl<T: RealField> Integrator<T> for WhittedIntegrator<T> {
.iter() .iter()
.map(|light| { .map(|light| {
match sampler match sampler
.sample(&Ray::new(info.location, light.direction).bias(convert(0.0000001))) .sample(&Ray::new(info.location, light.direction).bias(convert(0.000_000_1)))
{ {
Some(_) => self.ambient_light, Some(_) => self.ambient_light,
None => { None => {
@ -53,7 +53,7 @@ impl<T: RealField> Integrator<T> for WhittedIntegrator<T> {
let world_space_direction = bsdf_to_world_space * direction; let world_space_direction = bsdf_to_world_space * direction;
match sampler.sample( match sampler.sample(
&Ray::new(info.location, world_space_direction) &Ray::new(info.location, world_space_direction)
.bias(convert(0.0000001)), .bias(convert(0.000_000_1)),
) { ) {
Some(recursive_hit) => { Some(recursive_hit) => {
info.material.bsdf()( info.material.bsdf()(

View File

@ -115,9 +115,9 @@ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut event_pump = sdl_context.event_pump()?; let mut event_pump = sdl_context.event_pump()?;
let mut i = 0; let mut i = 0;
'running: loop { 'running: loop {
let tile_size = 128; let tile_size = 256;
for tile_row in 0..1 + (output_image.get_height() + 1) / tile_size { for tile_row in 0..=(output_image.get_height() + 1) / tile_size {
for tile_column in 0..1 + (output_image.get_width() + 1) / tile_size { for tile_column in 0..=(output_image.get_width() + 1) / tile_size {
let row_start = tile_row * tile_size; let row_start = tile_row * tile_size;
let row_end = min(tile_row * tile_size + tile_size, output_image.get_height()); let row_end = min(tile_row * tile_size + tile_size, output_image.get_height());
let column_start = tile_column * tile_size; let column_start = tile_column * tile_size;

View File

@ -19,7 +19,7 @@ impl<T: RealField> Ray<T> {
} }
pub fn point_at(&self, t: T) -> Vector3<T> { pub fn point_at(&self, t: T) -> Vector3<T> {
return self.origin + self.direction * t; self.origin + self.direction * t
} }
pub fn bias(&self, amount: T) -> Ray<T> { pub fn bias(&self, amount: T) -> Ray<T> {