-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
80 lines (61 loc) · 1.57 KB
/
main.lua
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
--[[
(c) 2021 marc2o
--]]
canvas = nil
image = nil
shader = nil
function love.load()
love.window.setMode(640, 480, {
fullscreen = false,
vsync = 1,
resizable = false,
centered = true }
)
love.window.setTitle("composite shader with scanlines")
canvas = love.graphics.newCanvas(320, 240)
canvas:setFilter("nearest", "nearest")
love.graphics.setLineStyle("rough")
image = love.graphics.newImage("Assets/Images/SMPTE_Color_Bars.png")
shader = require("Assets.Filters.compositeScanlines")
shader:send("screen", {
canvas:getWidth(),
canvas:getHeight()
})
end
function love.update(dt)
if dt < 1/60 then
love.timer.sleep(1/60 - dt)
end
end
function love.draw()
love.graphics.setBlendMode("alpha", "alphamultiply")
canvas:renderTo(
function()
love.graphics.setColor(1, 1, 1)
love.graphics.draw(image, 0, 0)
end
)
local buffer = nil
buffer = love.graphics.newCanvas(canvas:getDimensions())
buffer:setFilter("nearest", "nearest")
buffer:renderTo(
function()
love.graphics.setShader(shader)
love.graphics.draw(canvas, 0, 0)
love.graphics.setShader()
end
)
love.graphics.setColor(1, 1, 1)
love.graphics.setBlendMode("replace", "premultiplied")
love.graphics.push()
love.graphics.translate(0, 0)
love.graphics.scale(
love.graphics.getWidth() / canvas:getWidth(),
love.graphics.getHeight() / canvas:getHeight()
)
love.graphics.draw(buffer, 0, 0)
love.graphics.pop()
--love.graphics.captureScreenshot( "screenshot.png" )
end
function love.quit()
end