diff --git a/src/colors.rs b/src/colors.rs index a417ffc..f4a9ff8 100644 --- a/src/colors.rs +++ b/src/colors.rs @@ -4,30 +4,6 @@ use image::{DynamicImage, GenericImage, Rgba}; const GAMMA: f32 = 2.0; -/// normalizes the color for k rays on a single pixel -pub fn normalize_color_single_pixel(radiosity_vector: Vector4) -> Rgba { - - let radiosity_as_arr = [ - radiosity_vector.x, - radiosity_vector.y, - radiosity_vector.z, - ]; - - //linearly map luminosity values to [0..255] - let range: f32 = - radiosity_as_arr.iter().fold(f32::NEG_INFINITY, |a, b| a.max(*b)) - - radiosity_as_arr.iter().fold(f32::INFINITY, |a, b| a.min(*b)); - - let color_value: Vector4 = - radiosity_vector.map(|lum_val| - f32::ceil((lum_val / range) * 255.0) as u8 - ); - - //just make the pixel opaque - //TODO: consider alpha - Rgba([color_value.x, color_value.y, color_value.z, 255]) -} - pub fn normalize_colors_global(radiosity_buffer: &mut Vec>>) -> &Vec>> { //largest radiosity found yet let mut maximum_radiosity = f32::NEG_INFINITY; diff --git a/src/main.rs b/src/main.rs index d9f572a..35f9d15 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,6 +65,6 @@ fn main() { let output_image = store_colors_to_image(as_colors); - output_image.save("../output_image.png").expect("Unable to save image!"); + output_image.save("/home/clemens/repositorys/raytrace-rs/output_image.png").expect("Unable to save image!"); } diff --git a/src/renderer.rs b/src/renderer.rs index 5d3ff1b..d469dec 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -1,9 +1,7 @@ -use indicatif::ProgressIterator; use std::f32::consts::PI; use std::ops::{Add, Mul}; use std::sync::{Arc, Mutex}; use cgmath::{Angle, ElementWise, InnerSpace, Matrix4, Vector2, Vector3, Vector4}; -use cgmath::num_traits::abs; use rayon::iter::{IntoParallelIterator, ParallelIterator}; use easy_gltf::model::{Mode}; use easy_gltf::{Camera, Projection, Scene};