-
-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathScene.swift
93 lines (91 loc) · 3.07 KB
/
Scene.swift
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
import ChibiRay
func createDemoScene(size: Int) -> Scene {
return Scene(
width: size,
height: size,
fov: 90,
elements: [
.sphere(
Sphere(
center: Point(x: 1.0, y: -1.0, z: -7.0),
radius: 1.0,
material: Material(
color: Color(red: 0.8, green: 0.2, blue: 0.4),
albedo: 0.6,
surface: .reflective(reflectivity: 0.9)
)
)
),
.sphere(
Sphere(
center: Point(x: -2.0, y: 1.0, z: -10.0),
radius: 3.0,
material: Material(
color: Color(red: 1.0, green: 0.4, blue: 0.4),
albedo: 0.7,
surface: .diffuse
)
)
),
.sphere(
Sphere(
center: Point(x: 3.0, y: 2.0, z: -5.0),
radius: 2.0,
material: Material(
color: Color(red: 0.4, green: 0.4, blue: 0.8),
albedo: 0.5,
surface: .refractive(index: 2, transparency: 0.9)
)
)
),
.plane(
Plane(
origin: Point(x: 0.0, y: -2.0, z: -5.0),
normal: Vector3(x: 0.0, y: -1.0, z: 0.0),
material: Material(
color: Color(red: 1.0, green: 1.0, blue: 1.0),
albedo: 0.18,
surface: .reflective(reflectivity: 0.5)
)
)
),
.plane(
Plane(
origin: Point(x: 0.0, y: 0.0, z: -20.0),
normal: Vector3(x: 0.0, y: 0.0, z: -1.0),
material: Material(
color: Color(red: 0.2, green: 0.3, blue: 1.0),
albedo: 0.38,
surface: .diffuse
)
)
)
],
lights: [
.spherical(
SphericalLight(
position: Point(x: 5.0, y: 10.0, z: -3.0),
color: Color(red: 1.0, green: 1.0, blue: 1.0),
intensity: 16000
)
),
.spherical(
SphericalLight(
position: Point(x: -3.0, y: 3.0, z: -5.0),
color: Color(red: 0.3, green: 0.3, blue: 1.0),
intensity: 1000
)
),
.directional(
DirectionalLight(
direction: Vector3(x: 0.0, y: -1.0, z: -1.0),
color: Color(red: 0.8, green: 0.8, blue: 0.8),
intensity: 0.2
)
)
],
shadowBias: 1e-13,
maxRecursionDepth: 10
)
}
extension Scene: @retroactive @unchecked Sendable {}