Assorted changes.

This commit is contained in:
2017-02-28 14:49:47 -04:00
parent d5bd3174e1
commit 0095c138a4
4 changed files with 12 additions and 9 deletions

View File

@@ -3,3 +3,4 @@
-Wall -Wall
-DGLM_FORCE_RADIANS -DGLM_FORCE_RADIANS
-fopenmp -fopenmp
-std=c++11

View File

@@ -5,11 +5,11 @@ 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 \ 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 path_tracer.o whitted_tracer.o rgbe.o kd_tree.o photon_tracer.o
DEPENDS = $(OBJECTS:.o=.d) DEPENDS = $(OBJECTS:.o=.d)
CXXFLAGS = -ansi -pedantic -Wall -DGLM_FORCE_RADIANS -fopenmp CXXFLAGS = -ansi -pedantic -Wall -DGLM_FORCE_RADIANS -fopenmp -std=c++11
LDLIBS = -lfreeimage -ljson_spirit LDLIBS = -lfreeimage -ljson_spirit
.PHONY: all .PHONY: all
all: CXXFLAGS += -O2 -DNDEBUG all: CXXFLAGS += -O3 -DNDEBUG
all: $(TARGET) all: $(TARGET)
.PHONY: debug .PHONY: debug

View File

@@ -4,6 +4,7 @@
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <cstdint>
#include <unistd.h> #include <unistd.h>
#include <omp.h> #include <omp.h>
@@ -69,8 +70,8 @@ int main(int argc, char ** argv) {
vec2 sample; vec2 sample;
Tracer * tracer; Tracer * tracer;
PhotonTracer * p_tracer; PhotonTracer * p_tracer;
size_t total; uint64_t total;
size_t current = 0; uint64_t current = 0;
FIBITMAP * input_bitmap; FIBITMAP * input_bitmap;
FIBITMAP * output_bitmap; FIBITMAP * output_bitmap;
FREE_IMAGE_FORMAT fif; FREE_IMAGE_FORMAT fif;
@@ -122,7 +123,7 @@ int main(int argc, char ** argv) {
} }
// Generate the image. // Generate the image.
total = g_h * g_w * g_samples; total = static_cast<uint64_t>(g_h) * static_cast<uint64_t>(g_w) * static_cast<uint64_t>(g_samples);
cout << "Tracing a total of " << ANSI_BOLD_YELLOW << total << ANSI_RESET_STYLE << " primary rays:" << endl; cout << "Tracing a total of " << ANSI_BOLD_YELLOW << total << ANSI_RESET_STYLE << " primary rays:" << endl;
#pragma omp parallel for schedule(dynamic, 1) private(r, sample) shared(current) #pragma omp parallel for schedule(dynamic, 1) private(r, sample) shared(current)
for (int i = 0; i < g_h; i++) { for (int i = 0; i < g_h; i++) {
@@ -138,7 +139,7 @@ int main(int argc, char ** argv) {
image[i][j] /= g_samples; image[i][j] /= g_samples;
} }
#pragma omp critical #pragma omp critical
cout << "\r" << setw(3) << static_cast<size_t>((static_cast<double>(current) / static_cast<double>(total)) * 100.0) << "% done."; cout << "\r" << ANSI_BOLD_YELLOW << current << ANSI_RESET_STYLE << " of " << ANSI_BOLD_YELLOW << total << ANSI_RESET_STYLE << " primary rays traced.";
} }
cout << endl; cout << endl;

View File

@@ -2,6 +2,7 @@
#include <iomanip> #include <iomanip>
#include <limits> #include <limits>
#include <vector> #include <vector>
#include <cstdint>
#include <glm/gtc/constants.hpp> #include <glm/gtc/constants.hpp>
@@ -159,12 +160,12 @@ void PhotonTracer::build_photon_map(Scene * s, const size_t n_photons_per_ligth,
Vec3 ls, dir; Vec3 ls, dir;
float r1, r2; float r1, r2;
Photon ph; Photon ph;
size_t total = 0, current = 0; uint64_t total = 0, current = 0;
for (vector<Light *>::iterator it = s->m_lights.begin(); it != s->m_lights.end(); it++) { for (vector<Light *>::iterator it = s->m_lights.begin(); it != s->m_lights.end(); it++) {
total += (*it)->light_type() == Light::AREA ? 1 : 0; total += (*it)->light_type() == Light::AREA ? 1 : 0;
} }
total *= n_photons_per_ligth; total *= static_cast<uint64_t>(n_photons_per_ligth);
cout << "Tracing a total of " << ANSI_BOLD_YELLOW << total << ANSI_RESET_STYLE << " primary photons:" << endl; cout << "Tracing a total of " << ANSI_BOLD_YELLOW << total << ANSI_RESET_STYLE << " primary photons:" << endl;