-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheader.lua
More file actions
54 lines (42 loc) · 1.07 KB
/
header.lua
File metadata and controls
54 lines (42 loc) · 1.07 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
trace = require("trace")
vector = require("vectortypes")
shapegen = require("shapegen")
interval = require("interval")
camera = require("camera")
materials = require("materials")
_G.INFINITY = math.huge
_G.PI = math.pi
function DegreesToRadians(degrees)
return degrees * PI / 180
end
function random()
return math.random()
end
function randomrange(a,b)
return math.random() * (b-a) + a
end
local randomcolour = function ()
return instancevec3(random(),random(),random())
end
local randompos = function ()
return instancevec3(randomrange(-5,5),randomrange(0,3),randomrange(-10,-3))
end
local randommetal = function ()
return Metal(instancevec3(1,1,1), random())
end
local randomlambertian = function ()
return Lambertian(randomcolour())
end
local randommaterial = function ()
if random() > 0.5 then
return randommetal()
else
return randomlambertian()
end
end
local randomsize = function ()
return randomrange(0.5,2)
end
randomsphere = function ()
return Sphere(randompos(), randomsize(), randommaterial())
end