diff --git a/.clang_complete b/.clang_complete index 974eff0..3936014 100644 --- a/.clang_complete +++ b/.clang_complete @@ -1,6 +1,6 @@ --ansi +-std=c++11 -pedantic -Wall -DGLM_FORCE_RADIANS +-DUSE_CPP11_RANDOM -fopenmp --std=c++11 diff --git a/Gallery/jensen_primary-photons_2000000_radius_0.1_cone-filter_1.1_samples_1_exposure_-1_time_375m_45s.png b/Gallery/jensen_primary-photons_2000000_radius_0.1_cone-filter_1.1_samples_1_exposure_-1_time_375m_45s.png new file mode 100644 index 0000000..7903710 Binary files /dev/null and b/Gallery/jensen_primary-photons_2000000_radius_0.1_cone-filter_1.1_samples_1_exposure_-1_time_375m_45s.png differ diff --git a/Gallery/jensen_primary-photons_2000000_radius_0.1_cone-filter_1.1_samples_1_time_120m.png b/Gallery/jensen_primary-photons_2000000_radius_0.1_cone-filter_1.1_samples_1_time_120m.png new file mode 100644 index 0000000..fc6744e Binary files /dev/null and b/Gallery/jensen_primary-photons_2000000_radius_0.1_cone-filter_1.1_samples_1_time_120m.png differ diff --git a/Gallery/jensen_primary-photons_350000_radius_0.1_cone-filter_1.1_samples_10_time_247m_27s.png b/Gallery/jensen_primary-photons_350000_radius_0.1_cone-filter_1.1_samples_10_time_247m_27s.png new file mode 100644 index 0000000..7f64726 Binary files /dev/null and b/Gallery/jensen_primary-photons_350000_radius_0.1_cone-filter_1.1_samples_10_time_247m_27s.png differ diff --git a/Gallery/jensen_primary-photons_500000_radius_0.1_cone-filter_1.1_samples_10_time_1212m_28s.png b/Gallery/jensen_primary-photons_500000_radius_0.1_cone-filter_1.1_samples_10_time_1212m_28s.png new file mode 100644 index 0000000..d798e3e Binary files /dev/null and b/Gallery/jensen_primary-photons_500000_radius_0.1_cone-filter_1.1_samples_10_time_1212m_28s.png differ diff --git a/Gallery/montecarlo_furnace_test_samples_1000_time_1m_3s.png b/Gallery/montecarlo_furnace_test_samples_1000_time_1m_3s.png new file mode 100644 index 0000000..42e9302 Binary files /dev/null and b/Gallery/montecarlo_furnace_test_samples_1000_time_1m_3s.png differ diff --git a/Gallery/montecarlo_samples_100000_exposure_-2_time_235_m_17s.png b/Gallery/montecarlo_samples_100000_exposure_-2_time_235_m_17s.png new file mode 100644 index 0000000..ab0bee5 Binary files /dev/null and b/Gallery/montecarlo_samples_100000_exposure_-2_time_235_m_17s.png differ diff --git a/Gallery/montecarlo_samples_10000_exposure_-3_time_24m_24s.png b/Gallery/montecarlo_samples_10000_exposure_-3_time_24m_24s.png new file mode 100644 index 0000000..e456c25 Binary files /dev/null and b/Gallery/montecarlo_samples_10000_exposure_-3_time_24m_24s.png differ diff --git a/Gallery/montecarlo_samples_1000_exposure_-2_time_26m_33s.png b/Gallery/montecarlo_samples_1000_exposure_-2_time_26m_33s.png new file mode 100644 index 0000000..fe26dfb Binary files /dev/null and b/Gallery/montecarlo_samples_1000_exposure_-2_time_26m_33s.png differ diff --git a/Gallery/montecarlo_samples_25000_exposure_-2_time_2880m_approx.png b/Gallery/montecarlo_samples_25000_exposure_-2_time_2880m_approx.png new file mode 100644 index 0000000..05612cd Binary files /dev/null and b/Gallery/montecarlo_samples_25000_exposure_-2_time_2880m_approx.png differ diff --git a/Gallery/montecarlo_samples_5000_exposure_-0.5_time_19m_3s.png b/Gallery/montecarlo_samples_5000_exposure_-0.5_time_19m_3s.png new file mode 100644 index 0000000..4960366 Binary files /dev/null and b/Gallery/montecarlo_samples_5000_exposure_-0.5_time_19m_3s.png differ diff --git a/Gallery/whitted_samples_100_time_18s.png b/Gallery/whitted_samples_100_time_18s.png new file mode 100644 index 0000000..39eaf44 Binary files /dev/null and b/Gallery/whitted_samples_100_time_18s.png differ diff --git a/Makefile b/Makefile index 537b174..a3fd96a 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ OBJECTS = main.o sampling.o camera.o environment.o disk.o plane.o sphere.o \ spot_light.o sphere_area_light.o disk_area_light.o scene.o tracer.o \ path_tracer.o whitted_tracer.o rgbe.o kd_tree.o photon_tracer.o DEPENDS = $(OBJECTS:.o=.d) -CXXFLAGS = -std=c++11 -pedantic -Wall -DGLM_FORCE_RADIANS -fopenmp -D_USE_CPP11_RANDOM #-DENABLE_KD_TREE +CXXFLAGS = -std=c++11 -pedantic -Wall -DGLM_FORCE_RADIANS -fopenmp -DUSE_CPP11_RANDOM #-DENABLE_KD_TREE LDLIBS = -lfreeimage -ljson_spirit .PHONY: all diff --git a/hsa_brdf.hpp b/hsa_brdf.hpp index 2de8a69..7b9eea0 100644 --- a/hsa_brdf.hpp +++ b/hsa_brdf.hpp @@ -2,6 +2,8 @@ #ifndef HSA_BRDF_HPP #define HSA_BRDF_HPP +#include + #include "phong_brdf.hpp" using glm::normalize; diff --git a/photon_tracer.cpp b/photon_tracer.cpp index 1e226c3..2713b10 100644 --- a/photon_tracer.cpp +++ b/photon_tracer.cpp @@ -118,9 +118,16 @@ vec3 PhotonTracer::trace_ray(Ray & r, Scene * s, unsigned int rec_level) const { #else m_photon_map.find_by_distance(photons, i_pos, n, m_h_radius, 1000); #endif + while(photons.size() == 0 && radius < 5.0) { radius *= 2; +#ifdef ENABLE_KD_TREE + vmin = Vec3(i_pos.x - m_h_radius, i_pos.y - m_h_radius, i_pos.z - m_h_radius); + vmax = Vec3(i_pos.x + m_h_radius, i_pos.y + m_h_radius, i_pos.z + m_h_radius); + photons = m_photon_map.findInRange(vmin, vmax); +#else m_photon_map.find_by_distance(photons, i_pos, n, m_h_radius, 1000); +#endif } radius = m_h_radius; @@ -129,11 +136,17 @@ vec3 PhotonTracer::trace_ray(Ray & r, Scene * s, unsigned int rec_level) const { #else m_caustics_map.find_by_distance(caustics, i_pos, n, m_h_radius, 1000); #endif + while(caustics.size() == 0 && radius < 5.0) { radius *= 2; +#ifdef ENABLE_KD_TREE + vmin = Vec3(i_pos.x - m_h_radius, i_pos.y - m_h_radius, i_pos.z - m_h_radius); + vmax = Vec3(i_pos.x + m_h_radius, i_pos.y + m_h_radius, i_pos.z + m_h_radius); + photons = m_caustics_map.findInRange(vmin, vmax); +#else m_caustics_map.find_by_distance(caustics, i_pos, n, m_h_radius, 1000); +#endif } - //photons.insert(photons.end(), caustics.begin(), caustics.end()); for (Photon p : photons) { p.getColor(red, green, blue); diff --git a/sampling.cpp b/sampling.cpp index fbbd953..83be604 100644 --- a/sampling.cpp +++ b/sampling.cpp @@ -1,5 +1,4 @@ -#ifdef _USE_CPP11_RANDOM -#warning "Using C++11 random number generators." +#ifdef USE_CPP11_RANDOM #include #include #include @@ -13,7 +12,7 @@ #include "sampling.hpp" -#ifdef _USE_CPP11_RANDOM +#ifdef USE_CPP11_RANDOM using std::uniform_real_distribution; using std::mt19937; using std::bind; @@ -29,7 +28,7 @@ const float PDF = (1.0f / (2.0f * pi())); static bool seeded = false; -#ifdef _USE_CPP11_RANDOM +#ifdef USE_CPP11_RANDOM static uniform_real_distribution dist(0, 1); static mt19937 engine; static auto generator = bind(dist, engine); @@ -37,14 +36,14 @@ static auto generator = bind(dist, engine); float random01() { if (!seeded) { -#ifdef _USE_CPP11_RANDOM +#ifdef USE_CPP11_RANDOM engine.seed(std::chrono::system_clock::now().time_since_epoch().count()); #else srand(time(NULL)); #endif seeded = true; } -#ifdef _USE_CPP11_RANDOM +#ifdef USE_CPP11_RANDOM return generator(); #else return static_cast(rand()) / RAND_MAX;