Implement BVH

This commit is contained in:
CJSatnarine
2024-07-08 17:31:04 -04:00
parent 5ca33d1762
commit 80f3aff65d
18 changed files with 81908 additions and 351689 deletions

View File

@@ -1,4 +1,5 @@
#include "rayTracer.h"
#include "bvh.h"
#include "camera.h"
#include "hittable.h"
#include "hittableList.h"
@@ -9,18 +10,6 @@ int main(void) {
// World.
hittableList world;
// auto groundMaterial = make_shared<lambertian>(colour(0.1, 0.0, 0.0));
// auto centreMaterial = make_shared<lambertian>(colour(0.1, 0.2, 0.5));
// auto leftMaterial = make_shared<dielectric>(1.50);
// auto bubbleMaterial = make_shared<dielectric>(1.00 / 1.50);
// auto rightMaterial = make_shared<metal>(colour(1.0, 0.0, 0.0), 1.0);
// world.add(make_shared<sphere>(point3( 0.0, -100.5, -1.0), 100.0, groundMaterial));
// world.add(make_shared<sphere>(point3( 0.0, 0.0, -1.2), 0.5, centreMaterial));
// world.add(make_shared<sphere>(point3(-1.0, 0.0, -1.0), 0.5, leftMaterial));
// world.add(make_shared<sphere>(point3(-1.0, 0.0, -1.0), 0.4, bubbleMaterial));
// world.add(make_shared<sphere>(point3( 1.0, 0.0, -1.0), 0.5, rightMaterial));
// Code from the book.
auto ground_material = make_shared<lambertian>(colour(0.5, 0.5, 0.5));
world.add(make_shared<sphere>(point3(0,-1000,0), 1000, ground_material));
@@ -65,6 +54,8 @@ int main(void) {
auto material3 = make_shared<metal>(colour(0.7, 0.6, 0.5), 0.0);
world.add(make_shared<sphere>(point3(4, 1, 0), 1.0, material3));
world = hittableList(make_shared<bvh_node>(world));
// Camera.
camera cam;
cam.aspectRatio = 16.0 / 9.0;