Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (53 loc) · 2.5 KB
/
Copy pathmain.cpp
File metadata and controls
65 lines (53 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "Renderer.hpp"
#include "Scene.hpp"
#include "Triangle.hpp"
#include "Sphere.hpp"
#include "Vector.hpp"
#include "global.hpp"
#include <chrono>
// In the main function of the program, we create the scene (create objects and
// lights) as well as set the options for the render (image width and height,
// maximum recursion depth, field-of-view, etc.). We then call the render
// function().
int main(int argc, char** argv)
{
// Change the definition here to change resolution
Scene scene(784, 784);
//initialize diffuse material
Material* red = new Material(DIFFUSE, Vector3f(0.0f));
red->Kd = Vector3f(0.63f, 0.065f, 0.05f);
Material* green = new Material(DIFFUSE, Vector3f(0.0f));
green->Kd = Vector3f(0.14f, 0.45f, 0.091f);
Material* white = new Material(DIFFUSE, Vector3f(0.0f));
white->Kd = Vector3f(0.725f, 0.71f, 0.68f);
Material* light = new Material(DIFFUSE, (8.0f * Vector3f(0.747f+0.058f, 0.747f+0.258f, 0.747f) + 15.6f * Vector3f(0.740f+0.287f,0.740f+0.160f,0.740f) + 18.4f *Vector3f(0.737f+0.642f,0.737f+0.159f,0.737f)));
light->Kd = Vector3f(0.65f);
//initialize Microfacet material
Material* MicrofacetMat=new Material(Microfacet,Vector3f(0.0f));
MicrofacetMat->Kd=Vector3f(0.2f,0.2f,0.2f);
MicrofacetMat->Ks=Vector3f(0.7f,0.7f,0.7f);
Sphere sphere(Vector3f(150.f,100.f,300.f),100.0,MicrofacetMat);
MeshTriangle floor(".\\models\\cornellbox\\floor.obj", white);
MeshTriangle shortbox(".\\models\\cornellbox\\shortbox.obj", white);
MeshTriangle tallbox(".\\models\\cornellbox\\tallbox.obj", white);
MeshTriangle left(".\\models\\cornellbox\\left.obj", red);
MeshTriangle right(".\\models\\cornellbox\\right.obj", green);
MeshTriangle light_(".\\models\\cornellbox\\light.obj", light);
scene.Add(&floor);
scene.Add(&shortbox);
scene.Add(&tallbox);
scene.Add(&left);
scene.Add(&right);
scene.Add(&light_);
//scene.Add(&sphere);
scene.buildBVH();
Renderer r;
auto start = std::chrono::system_clock::now();
r.Render(scene);
auto stop = std::chrono::system_clock::now();
std::cout << "Render complete: \n";
std::cout << "Time taken: " << std::chrono::duration_cast<std::chrono::hours>(stop - start).count() << " hours\n";
std::cout << " : " << std::chrono::duration_cast<std::chrono::minutes>(stop - start).count() << " minutes\n";
std::cout << " : " << std::chrono::duration_cast<std::chrono::seconds>(stop - start).count() << " seconds\n";
return 0;
}