-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
186 lines (179 loc) · 4.46 KB
/
main.go
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
package main
import (
"fmt"
"os"
"github.com/achilleasa/polaris/cmd"
"github.com/urfave/cli"
)
var (
sceneCompileHelp = `
Parse a scene definition from a wavefront obj file, build a BVH tree to optimize
ray intersection tests and package scene assets in a GPU-friendly format.
The optimized scene data is then written to a zip archive which can be supplied
as an argument to the render commands.
`
)
func main() {
cli.VersionFlag = cli.BoolFlag{
Name: "version",
Usage: "print only the version",
}
app := cli.NewApp()
app.Name = "polaris"
app.Usage = "render scenes using path tracing"
app.Version = "0.0.1"
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "v",
Usage: "enable verbose logging",
},
cli.BoolFlag{
Name: "vv",
Usage: "enable even more verbose logging",
},
}
app.Commands = []cli.Command{
{
Name: "scene",
Subcommands: []cli.Command{
{
Name: "compile",
Usage: "compile text scene representation into a binary compressed format",
Description: sceneCompileHelp,
ArgsUsage: "scene_file1.obj scene_file2.obj ...",
Action: cmd.CompileScene,
},
{
Name: "info",
Usage: "print the size of the various compiled scene assets",
ArgsUsage: "scene_file.zip",
Action: cmd.ShowSceneInfo,
},
},
},
{
Name: "list-devices",
Usage: "list available opencl devices",
Action: cmd.ListDevices,
},
{
Name: "render",
Usage: "render scene",
Action: nil,
Subcommands: []cli.Command{
{
Name: "frame",
Usage: "render single frame",
Description: `Render a single frame.`,
ArgsUsage: "scene_file.zip or scene_file.obj",
Flags: []cli.Flag{
cli.IntFlag{
Name: "width",
Value: 1024,
Usage: "frame width",
},
cli.IntFlag{
Name: "height",
Value: 1024,
Usage: "frame height",
},
cli.IntFlag{
Name: "spp",
Value: 16,
Usage: "samples per pixel",
},
cli.IntFlag{
Name: "num-bounces, nb",
Value: 5,
Usage: "number of indirect ray bounces",
},
cli.IntFlag{
Name: "rr-bounces, nr",
Value: 3,
Usage: "number of indirect ray bounces before applying RR (disabled if 0 or >= than num-bounces)",
},
cli.Float64Flag{
Name: "exposure",
Value: 1.2,
Usage: "camera exposure for tone-mapping",
},
cli.StringSliceFlag{
Name: "blacklist, b",
Value: &cli.StringSlice{},
Usage: "blacklist opencl device whose names contain this value",
},
cli.StringFlag{
Name: "force-primary",
Value: "",
Usage: "force a particular device name as the primary device",
},
cli.StringFlag{
Name: "out, o",
Value: "frame.png",
Usage: "image filename for the rendered frame",
},
},
Action: cmd.RenderFrame,
},
{
Name: "interactive",
Usage: "render interactive view of the scene",
Description: ``,
Flags: []cli.Flag{
cli.IntFlag{
Name: "width",
Value: 1024,
Usage: "frame width",
},
cli.IntFlag{
Name: "height",
Value: 1024,
Usage: "frame height",
},
cli.IntFlag{
Name: "spp",
Value: 0,
Usage: "samples per pixel; setting to 0 enables progressive rendering",
},
cli.IntFlag{
Name: "num-bounces, nb",
Value: 5,
Usage: "number of indirect ray bounces",
},
cli.IntFlag{
Name: "rr-bounces, nr",
Value: 3,
Usage: "number of indirect ray bounces before applying RR (disabled if 0 or >= than num-bounces)",
},
cli.Float64Flag{
Name: "exposure",
Value: 1.2,
Usage: "camera exposure for tone-mapping",
},
cli.StringSliceFlag{
Name: "blacklist, b",
Value: &cli.StringSlice{},
Usage: "blacklist opencl device whose names contain this value",
},
cli.StringFlag{
Name: "force-primary",
Value: "",
Usage: "force a particular device name as the primary device",
},
cli.StringFlag{
Name: "scheduler",
Value: "perfect",
Usage: "select a particular block scheduling algorithm; supported algorithms: naive, perfect",
},
},
Action: cmd.RenderInteractive,
},
},
},
}
err := app.Run(os.Args)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}