Skip to content

Commit

Permalink
now bvh is making some difference
Browse files Browse the repository at this point in the history
  • Loading branch information
alysssssa committed May 1, 2023
1 parent b73386f commit 0aae8b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 2 additions & 0 deletions raytracer/bvh.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "hittable.h"
#include "hittable_list.h"

#include <algorithm>

// bounding volume hierarchy

class bvh_node : public hittable {
Expand Down
9 changes: 6 additions & 3 deletions raytracer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "camera.h"
#include "material.h"
#include "moving_sphere.h"
#include "bvh.h"

#include <iostream>

Expand Down Expand Up @@ -58,8 +59,10 @@ hittable_list random_scene() {
if (choose_mat < 0.8) {
auto albedo = colour::random() * colour::random();
sphere_material = make_shared<lambertian>(albedo);
auto center2 = center + vec3(0, random_double(0, 0.5), 0);
world.add(make_shared<moving_sphere>(center, center2, 0.0, 1.0, 0.2, sphere_material));
world.add(make_shared<sphere>(center, 0.2, sphere_material));
// motion blur
// auto center2 = center + vec3(0, random_double(0, 0.5), 0);
// world.add(make_shared<moving_sphere>(center, center2, 0.0, 1.0, 0.2, sphere_material));
// metal
} else if (choose_mat < 0.95) {
auto albedo = colour::random(0.5, 1);
Expand All @@ -84,7 +87,7 @@ hittable_list random_scene() {
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));

return world;
return hittable_list(make_shared<bvh_node>(world, 0.0, 1.0));
}

int main() {
Expand Down

0 comments on commit 0aae8b3

Please sign in to comment.