From 3549acb5dbd2f6fe43be6cce9828785ccead7e77 Mon Sep 17 00:00:00 2001 From: Nat Lasseter Date: Fri, 14 Jun 2024 12:23:49 +0100 Subject: Finished! Good god performance nope. --- rtiaw | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 12 deletions(-) (limited to 'rtiaw') diff --git a/rtiaw b/rtiaw index 234aa85..f8a6700 100755 --- a/rtiaw +++ b/rtiaw @@ -10,20 +10,61 @@ require 'hittable' require 'camera' require 'material' -mat_ground = Lambertian.new(0.8, 0.8, 0.0) -mat_centre = Lambertian.new(0.1, 0.2, 0.5) -mat_left = Dielectric.new(1.5) -mat_bubble = Dielectric.new(1 / 1.5) -mat_right = Metal.new(0.8, 0.6, 0.2, 1.0) +#mat_ground = Lambertian.new(Colour.new(0.8, 0.8, 0.0)) +#mat_centre = Lambertian.new(Colour.new(0.1, 0.2, 0.5)) +#mat_left = Dielectric.new(1.5) +#mat_bubble = Dielectric.new(1 / 1.5) +#mat_right = Metal.new(Colour.new(0.8, 0.6, 0.2), 1.0) +# +#world = Hittables.new +#world << Sphere.new(Point.new( 0, -100.5, -1), 100, mat_ground) +#world << Sphere.new(Point.new( 0, 0, -1.2), 0.5, mat_centre) +#world << Sphere.new(Point.new(-1, 0, -1), 0.5, mat_left) +#world << Sphere.new(Point.new(-1, 0, -1), 0.4, mat_bubble) +#world << Sphere.new(Point.new( 1, 0, -1), 0.5, mat_right) +# +#camera = Camera.new(400, 16.0 / 9, +# vfov: 20, +# lookfrom: Point.new(-2,2,1), +# defocus_angle: 10, focus_dist: 3.4) +#camera.render(world) world = Hittables.new -world << Sphere.new( 0, -100.5, -1, 100, mat_ground) -world << Sphere.new( 0, 0, -1.2, 0.5, mat_centre) -world << Sphere.new(-1, 0, -1, 0.5, mat_left) -world << Sphere.new(-1, 0, -1, 0.4, mat_bubble) -world << Sphere.new( 1, 0, -1, 0.5, mat_right) + +mat_ground = Lambertian.new(Colour.new(0.5, 0.5, 0.5)) +world << Sphere.new(Point.new(0.0, -1000.0, 0.0), 1000.0, mat_ground) + +(-4...4).each do |a| + (-4...4).each do |b| + centre = Point.new(a + 0.9 * rand, 0.2, b + 0.9 * rand) + if (centre - Point.new(4, 0.2, 0)).mag > 0.9 + s_mat = case rand + when 0...0.8 + albedo = Colour.random * Colour.random + Lambertian.new(albedo) + when 0.8...0.95 + albedo = Colour.random(min: 0.5, max: 1) + fuzz = rand(0...0.5) + Metal.new(albedo, fuzz) + else + Dielectric.new(1.5) + end + world << Sphere.new(centre, 0.2, s_mat) + end + end +end + +mat1 = Dielectric.new(1.5) +world << Sphere.new(Point.new(0.0, 1.0, 0.0), 1.0, mat1) +mat2 = Lambertian.new(Colour.new(0.4, 0.2, 0.1)) +world << Sphere.new(Point.new(-4.0, 1.0, 0.0), 1.0, mat2) +mat3 = Metal.new(Colour.new(0.7, 0.6, 0.5), 0.0) +world << Sphere.new(Point.new(4.0, 1.0, 0.0), 1.0, mat3) camera = Camera.new(400, 16.0 / 9, - vfov: 20, - lookfrom: Point.new(-2,2,1)) + aliasing: 4, depth: 4, + vfov: 20.0, + lookfrom: Point.new(13.0, 2.0, 3.0), + lookat: Point.new, + defocus_angle: 0.6, focus_dist: 10.0) camera.render(world) -- cgit v1.2.1