-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscene.h
More file actions
57 lines (50 loc) · 1.51 KB
/
Copy pathscene.h
File metadata and controls
57 lines (50 loc) · 1.51 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
#pragma once
#include "vector.h"
#include "shapes.h"
#include "background.h"
#include <vector>
class Light;
enum ToneMapType {
TONEMAP_NONE,
TONEMAP_REINHARD,
TONEMAP_ACES
};
class Scene {
public:
std::vector<Shape3D*> shapes;
std::vector<Light*> lights;
int width = 800;
int height = 600;
int samples_per_pixel = 500;
int max_bounces = 10;
int fov = 70; // Degrees
Vector3 camera_position = Vector3(0, 0, 0);
Vector3 camera_cframe[3] = {
Vector3(1, 0, 0),
Vector3(0, 1, 0),
Vector3(0, 0, -1)
}; // Right, Up, Forward
ToneMapType tone_map = TONEMAP_REINHARD;
Background* background = nullptr;
Scene() {}
~Scene() {
for (auto shape : shapes) {
delete shape;
}
}
void addShape(Shape3D* shape) {
shapes.push_back(shape);
}
void addLight(Light* light) {
lights.push_back(light);
}
void rotateCamera(Vector3 euler);
void setCameraRotation(Vector3 euler);
CollisionInfo intersectRay(Vector3& origin, Vector3& direction, Vector3& inv_dir) const;
std::vector<Vector3> render();
std::vector<Vector3> renderThreaded(int num_threads, int tile_size = 8);
std::vector<CollisionInfo> renderCollisionInfo();
void renderDebug(std::vector<Vector3>* normals = nullptr, std::vector<double>* depth = nullptr, std::vector<Vector3>* albedo = nullptr);
private:
void renderTile(int start_x, int start_y, int tile_width, int tile_height, std::vector<Vector3>& framebuffer);
};