-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathmain.go
77 lines (65 loc) · 1.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
package main
import (
"fmt"
"math"
"github.com/unixpickle/model3d/model3d"
"github.com/unixpickle/model3d/render3d"
)
const HighRes = false
func main() {
scene := render3d.JoinedObject{
NewFloorObject(),
NewDomeObject(),
NewLightObject(),
ReadVase(),
ReadRose(),
ReadWineGlass(),
ReadPumpkin(),
ReadRocks(),
ReadCurvyThing(),
}
RenderScene(scene)
}
func RenderScene(scene render3d.Object) {
renderer := render3d.RecursiveRayTracer{
Camera: render3d.NewCameraAt(model3d.Coord3D{Y: CameraY, Z: CameraZ},
model3d.Coord3D{Y: RoomRadius, Z: CameraZ}, math.Pi/3.6),
FocusPoints: []render3d.FocusPoint{
&render3d.SphereFocusPoint{
Center: LightCenter,
Radius: LightRadius,
MaterialFilter: func(m render3d.Material) bool {
switch m.(type) {
case *render3d.PhongMaterial:
return true
case *render3d.LambertMaterial:
return true
}
return false
},
},
},
FocusPointProbs: []float64{0.3},
MaxDepth: 10,
NumSamples: 50,
Antialias: 1.0,
Cutoff: 1e-4,
LogFunc: func(p, samples float64) {
fmt.Printf("\rRendering %.1f%%...", p*100)
},
}
width := 480
height := 320
if HighRes {
width *= 2
height *= 2
renderer.NumSamples = 100000
renderer.MinSamples = 1000
renderer.MaxStddev = 0.02
}
fmt.Println("Variance:", renderer.RayVariance(scene, 200, 133, 2))
img := render3d.NewImage(width, height)
renderer.Render(img, scene)
fmt.Println()
img.Save("output.png")
}