-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtrace.cpp
More file actions
79 lines (60 loc) · 1.66 KB
/
trace.cpp
File metadata and controls
79 lines (60 loc) · 1.66 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// SPDX-License-Identifier: Apache-2.0
// Copyright Contributors to the OpenQMC Project.
#include "write.h"
#include <trace.h>
#include <vector.h>
#include <cstdio>
#include <cstdlib>
float3* start(int width, int height)
{
return new float3[width * height];
}
void stop(float3* out)
{
delete[] out;
}
int main(int argc, char* argv[])
{
if(argc == 1)
{
std::fprintf(stderr, "No arguments passed; "
"user must specify a sampler and a scene.\n");
return EXIT_FAILURE;
}
if(argc < 3)
{
std::fprintf(stderr, "Too few arguments passed; "
"user must specify a sampler and a scene.\n");
return EXIT_FAILURE;
}
if(argc > 3)
{
std::fprintf(stderr, "Too many arguments passed; "
"user must specify a sampler and a scene.\n");
return EXIT_FAILURE;
}
constexpr auto mode = "split";
constexpr auto width = 1080;
constexpr auto height = 720;
constexpr auto frame = 0;
constexpr auto numPixelSamples = 2;
constexpr auto numLightSamples = 1;
constexpr auto maxDepth = 0;
constexpr auto maxOpacity = 2;
auto out = start(width, height);
if(!oqmc_trace(argv[1], argv[2], mode, width, height, frame,
numPixelSamples, numLightSamples, maxDepth, maxOpacity, out))
{
std::fprintf(stderr, "Configuration that was requested was not found; "
"sampler options are pmj, pmjbn, sobol, sobolbn, "
"lattice, latticebn, rng; "
"scene options are box, presence, blur.\n");
goto failure;
}
write::colours("image.pfm", width, height, out);
stop(out);
return EXIT_SUCCESS;
failure:
stop(out);
return EXIT_FAILURE;
}