Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- assert(love.graphics, 'This module require love.graphics module')
- local graphics = love.graphics
- local buffer = graphics.newCanvas()
- local resX, resY = graphics.getDimensions()
- return function(canvas, shader, clear)
- assert(canvas:type() == 'Canvas', 'Argument #1 error: love2d-canvas expected. Use post processing only with canvases.')
- assert(shader:type() == 'Shader', 'Argument #2 error: love2d-shader expected.')
- local x, y = graphics.getDimensions()
- if x ~= resX or y ~= resY then buffer = graphics.newCanvas(); resX, resY = x, y end
- graphics.push('all')
- graphics.setCanvas(buffer)
- if clear then graphics.clear(0.0, 0.0, 0.0, 0.0) end
- graphics.setShader(shader) graphics.draw(canvas) graphics.setShader()
- graphics.setCanvas(canvas) graphics.draw(buffer)
- graphics.pop()
- end
- --[[
- Reference:
- postprocessing = require 'module' -- replace 'module' to your file
- framebuffer = love.graphics.newCanvas()
- love.graphics.setCanvas(framebuffer)
- --draw any stuff
- love.graphics.setCanvas()
- postprocessing(framebuffer, shader1) -- apply first shader
- postprocessing(framebuffer, shader2) -- apply second shader
- love.graphics.draw(framebuffer) -- draw buffers with postprocessing
- ]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement