DIsable antialiasing if running with just one sample per pixel

This commit is contained in:
Jonathan Flueren 2022-07-17 21:09:39 +02:00
parent e09b0a9e1d
commit de559b02d7

View file

@ -264,13 +264,13 @@ fn main() {
// Image
let aspect_ratio = 16.0 / 9.0;
let image_width = 600;
let image_width = 1000;
let image_height = (image_width as f64 / aspect_ratio) as u32;
let samples_per_pixel = 50_u32;
let samples_per_pixel = 1_u32;
let max_depth = 50;
let vfov = 50.0;
let lookfrom = Point3::new(30.0, 20.0, 30.0);
let lookfrom = Point3::new(-30.0, 20.0, -30.0);
let lookat = Point3::new(0.0, 15.0, 0.0);
let vup = Vec3::new(0.0, 1.0, 0.0);
let dist_to_focus = 40.0;
@ -317,8 +317,15 @@ fn main() {
let mut colors = Vec::new();
for i in 0..image_width {
let mut pixel_color = Color::new(0.0, 0.0, 0.0);
for _ in 0..samples_per_pixel {
let mut pixel_color = ray_color(
&cam.get_ray(
i as f64 / (image_width - 1) as f64,
j as f64 / (image_height - 1) as f64,
),
&world,
max_depth,
); // first ray not antialiased to disable antialiasing on value 1
for _ in 1..samples_per_pixel {
let u = (i as f64 + utility::random_f64()) / (image_width - 1) as f64;
let v = (j as f64 + utility::random_f64()) / (image_height - 1) as f64;
let r = cam.get_ray(u, v);