I'm not sure why what I'm doing isn't working!
This is my code:
Code: Select all
shaders = {}
--Grayscale
shaders.grayscale = love.graphics.newShader[[
extern number factor;
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords ){
vec4 pixel = Texel(texture, texture_coords );//This is the current pixel color
number average = (pixel.r+pixel.b+pixel.g)/3.0;
pixel.r = pixel.r + (average-pixel.r) * factor;
pixel.g = pixel.g + (average-pixel.g) * factor;
pixel.b = pixel.b + (average-pixel.b) * factor;
pixel.a = pixel.a;
return pixel;
}
]]
function love.load()
background = love.graphics.newImage("backing.png")
icon = love.graphics.newImage("icon.png")
love.window.setMode(background:getDimensions())
shader = false
end
function love.draw()
--Set the shader
if shader then
love.graphics.setShader(shaders.grayscale)
shaders.grayscale:send("factor",0)
end
love.graphics.draw(background)
love.graphics.setColor(1,1,1,0.2)
love.graphics.draw(icon,60,60)
love.graphics.setColor(1,1,1,1)
--Reset the shader
love.graphics.setShader()
end
Code: Select all
pixel.a = pixel.a
Thanks for any help!!