Taehl wrote:Plausible? I guess anything's possible, if you want to completely disregard performance.(...) spritebatch - this would give you a huge performance boost.
Spritebatches are in fact not faster than drawing the images yourself. Framebuffers are the fastest method to draw static things.
tentus wrote:It's plausible, but here's the problem you will run into if you just scale framebuffers:
Interesting effect, but not what I meant. What I meant was something along this (some tweaking with the scale parameters required):
Code: Select all
-- .love attached, see below.
function love.load()
-- create framebuffer info
local function scaled_fb(scale)
return {
scale = scale,
fb = love.graphics.newFramebuffer(800 * scale, 600 * scale),
}
end
-- create framebuffers
fbs = {}
for i = 1,3 do
fbs[i] = scaled_fb(.2 + i * .05)
end
love.graphics.setLine(5)
end
-- return function that renders scaled scene
function render(scale, alpha)
return function()
love.graphics.push()
love.graphics.scale(scale,scale)
love.graphics.setColor(200,240,140, alpha)
love.graphics.circle('line', 300,300, 50, 32)
love.graphics.setColor(120,100,250, alpha)
love.graphics.rectangle('line', 500,200,100,200)
love.graphics.setColor(100,240,140, alpha)
love.graphics.circle('line', 100,400,100,6)
love.graphics.pop()
end
end
function love.draw()
-- render scene to framebuffers
for i, info in ipairs(fbs) do
info.fb:renderTo(render(info.scale, 180))
end
if not love.keyboard.isDown('b') then
-- blur pass
love.graphics.setBlendMode('additive')
love.graphics.setColor(255,255,255)
for i, info in ipairs(fbs) do
love.graphics.draw(info.fb, 0,0, 0, 1 / info.scale)
end
end
-- draw scene
render(1)()
love.graphics.setBlendMode('alpha')
love.graphics.setColor(255,255,255)
love.graphics.print('FPS: ' .. love.timer.getFPS(), 10,10)
end
The result:
- crappy-blur.jpg (15.6 KiB) Viewed 1048 times
As opposed to without blur:
- crappy-no-blur.jpg (12.42 KiB) Viewed 1048 times
Edit: This is not PO2 safe, so it might not work for everyone...