23 lines
585 B
Lua
23 lines
585 B
Lua
|
local GrayScale = {}
|
||
|
|
||
|
local greyscaleShader = love.graphics.newShader[[
|
||
|
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 = average;
|
||
|
pixel.g = average;
|
||
|
pixel.b = average;
|
||
|
return pixel;
|
||
|
}
|
||
|
]]
|
||
|
|
||
|
|
||
|
function GrayScale.startShader()
|
||
|
love.graphics.setShader(greyscaleShader)
|
||
|
end
|
||
|
|
||
|
function GrayScale.endShader()
|
||
|
love.graphics.setShader()
|
||
|
end
|
||
|
|
||
|
return GrayScale
|