-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpheres.lua
More file actions
72 lines (70 loc) · 1.47 KB
/
Copy pathSpheres.lua
File metadata and controls
72 lines (70 loc) · 1.47 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
scene = {
height = 9 * 30,
width = 16 * 30,
samples_per_pixel = 100,
maximum_bounces = 50,
textures = {{"env", "env2.jpg"}},
camera = {
position = {0, 2, -2},
looking_at = {0, 0.7, 0.5},
focal_length = 1,
field_of_view = 1.57,
upward_vector = {0, 1, 0},
defocus_angle = 0,
background_texture = {
tag = "image-texture",
image = "env",
style = {
tag = "stretch"
}
}
},
world = {{
tag = "sphere",
transform = {
{
tag = "translate",
contents = {0, 0.7, 0.5}
}
},
material = {
tag = "metal",
fuzz = 0,
texture = {
tag = "solid-color",
color = {255, 143, 107}
}
}
}}
}
for i = 0, 100 do
materalRoll = math.random(3)
mat = {
texture = {
tag = "solid-color",
color = {math.random(255), math.random(255), math.random(255)}
}
}
if materalRoll == 1 then
mat["tag"] = "lambertian"
elseif materalRoll == 2 then
mat["tag"] = "metal"
mat["fuzz"] = math.random() * 0.5
elseif materalRoll == 3 then
mat["tag"] = "emissive"
end
table.insert(scene.world, {
tag = "sphere",
transform = {
{
tag = "translate",
contents = {math.random(-10, 10), math.random(-1, 2), math.random(-10, 10)}
},
{
tag = "scale",
contents = {0.3 + (math.random() * 0.2), 0.3 + (math.random() * 0.2), 0.3 + (math.random() * 0.2)}
}
},
material = mat
})
end