-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
68 lines (49 loc) · 2.12 KB
/
main.lua
File metadata and controls
68 lines (49 loc) · 2.12 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
love = require("love")
hittable = require("hittable")
header = require("header")
function love.load()
_G.camera = Camera()
_G.RES_X, camera.x = love.graphics.getWidth(), love.graphics.getWidth()
_G.RES_Y, camera.y = love.graphics.getHeight(), love.graphics.getHeight()
camera.initialize()
_G.world = HittableList()
genericmirror = Metal(instancevec3(0.9,0.9,0.9), 0.8)
genericmatte = Lambertian(instancevec3(1,0.2,0.2))
glass = Dielectric(1/1.33, instancevec3(1,1,1))
glasshollow = Dielectric(1.33, instancevec3(1,1,1))
for i=1,10 do
world.add(randomsphere())
end
world.add(Sphere(instancepoint3(0,0.3,-2.75),0.5, Lambertian(instancevec3(0,1,0))))
world.add(Sphere(instancepoint3(-1,0.0,-1.5),0.5, genericmirror))
world.add(Sphere(instancepoint3(1,0.0,-1.5),0.5, Lambertian(instancevec3(0,0,1))))
world.add(Sphere(instancepoint3(0,0.3,-0.91),0.5, glass))
world.add(Sphere(instancepoint3(0,0.3,-0.91),0.4, glasshollow))
world.add(Sphere(instancepoint3(0,-30.5, -1), 30, genericmatte)) -- the ground Sphere
end
function love.resize(w, h)
_G.RES_X, camera.x = love.graphics.getWidth(), love.graphics.getWidth()
_G.RES_Y, camera.y = love.graphics.getHeight(), love.graphics.getHeight()
camera.ASPECT_RATIO = RES_X/RES_Y
camera.initialize()
end
function love.update(dt)
if camera.buffer:getWidth() ~= RES_X or camera.buffer:getHeight() ~= RES_Y then
camera.buffer = love.image.newImageData(RES_X, RES_Y)
end
camera.buffer:mapPixel(camera.renderpixel)
if camera.upscaling > 1 then
camera.buffer:mapPixel(camera.nearestneighbor)
end
camera.noisereduction = camera.noisereduction + 1
print("NOISE REDUCTION :", camera.noisereduction)
end
function love.draw()
if camera.screen:getWidth() ~= camera.buffer:getWidth() or camera.screen:getHeight() ~= camera.buffer:getHeight() then
print("CHANGING RES TO MATCH NEW WINDOW SIZE")
camera.screen = love.graphics.newArrayImage(camera.buffer)
else
camera.screen:replacePixels(camera.buffer, 1)
end
love.graphics.draw(camera.screen)
end