Skip to content
tanema edited this page Dec 5, 2014 · 4 revisions

Usage

The postshader can be used in two ways.

with the light world

lightWorld = LightWorld({
  --options
})
lightWorld.post_shader:addEffect("black_and_white")
-- now the call to lightworld:draw() will have the black and white postshader active

on its own independantly

local PostShader = require "lib/postshader"
post_shader = PostShader()
post_shader:addEffect("black_and_white")
render_buffer = love.graphics.newCanvas(love.window.getWidth(), love.window.getHeight())

function love.draw()
  render_buffer:clear()
  love.graphics.push()
    love.graphics.setCanvas(render_buffer)
    love.graphics.setColor(63, 255, 127)
    love.graphics.circle("fill", 256, 256, 16)
  love.graphics.pop()
  love.graphics.setCanvas()
  post_shader:drawWith(render_buffer)
end

:refreshScreenSize(w, h)

defaults: w, h will be set to the screen size

This will refresh the canvas sizes needed for postshader rendering. If you are using postshaders with the light world you do not need to call this if you are already calling lightWorld:refreshScreenSize()

:addEffect(shaderName, ...)

adds the postshader by the shader name and the rest of the arguments are those that are delegated to the postshader

shaderName refers to the shader file name to user so if it is scanlines.glsl the shader name will be "scanlines" The arguments correspond to the extern variables in the shaders, in order. (variables like screen are filled in automtically by the postshader)

:removeEffect(shaderName)

remove postshader from being active by name

:toggleEffect(shaderName, ...)

if the shader is active it will become inactive, if the shader has not been added then it will be added

:drawWith(canvas)

apply the postshader effect onto the canvas provided

Clone this wiki locally