From df7dc0f1069e6ed8ea24c152eb4c3a5a97e80b91 Mon Sep 17 00:00:00 2001 From: ladevieq Date: Sat, 19 Jun 2021 17:54:16 +0200 Subject: Split on the largest axis on BVH generation --- src/utils.cpp | 56 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'src/utils.cpp') diff --git a/src/utils.cpp b/src/utils.cpp index 6db101c..a754b1d 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -59,34 +59,34 @@ uint32_t random_scene(sphere *world) { uint32_t world_sphere_index = 1; int32_t spheres_count = 11; - // for (int a = -spheres_count; a < spheres_count; a++) { - // for (int b = -spheres_count; b < spheres_count; b++) { - // auto choose_mat = randd(); - // point3 center(a + 0.9 * randd(), 0.2, b + 0.9 * randd()); - - // if ((center - point3{ 4, 0.2, 0 }).length() > 0.9) { - // material sphere_material = {}; - - // if (choose_mat < 0.8) { - // // diffuse - // sphere_material.albedo = color::random() * color::random(); - // sphere_material.type = MATERIAL_TYPE::LAMBERTIAN; - // } else if (choose_mat < 0.95) { - // // metal - // sphere_material.albedo = color::random(0.5, 1); - // sphere_material.fuzz = randd(0, 0.5); - // sphere_material.type = MATERIAL_TYPE::METAL; - // } else { - // // glass - // sphere_material.ior = 1.5; - // sphere_material.type = MATERIAL_TYPE::DIELECTRIC; - // } - - // world[world_sphere_index] = { center, sphere_material, 0.2 }; - // world_sphere_index++; - // } - // } - // } + for (int a = -spheres_count; a < spheres_count; a++) { + for (int b = -spheres_count; b < spheres_count; b++) { + auto choose_mat = randd(); + point3 center(a + 0.9 * randd(), 0.2, b + 0.9 * randd()); + + if ((center - point3{ 4, 0.2, 0 }).length() > 0.9) { + material sphere_material = {}; + + if (choose_mat < 0.8) { + // diffuse + sphere_material.albedo = color::random() * color::random(); + sphere_material.type = MATERIAL_TYPE::LAMBERTIAN; + } else if (choose_mat < 0.95) { + // metal + sphere_material.albedo = color::random(0.5, 1); + sphere_material.fuzz = randd(0, 0.5); + sphere_material.type = MATERIAL_TYPE::METAL; + } else { + // glass + sphere_material.ior = 1.5; + sphere_material.type = MATERIAL_TYPE::DIELECTRIC; + } + + world[world_sphere_index] = { center, sphere_material, 0.2 }; + world_sphere_index++; + } + } + } material material1 = {}; material1.ior = 1.5; -- cgit v1.3