Untested:Ref wrote:Anybody create a Sobel (edge detection) PixelEffect
Code: Select all
effect = love.graphics.newPixelEffect[[
extern vec2 pixel_size;
vec4 effect(vec4 color, Image tex, vec2 tc, vec2 pixel_coords)
{
color = vec4(0.0);
// the kernel
color += 1. * Texel(tex, tc + vec2(-1./pixel_size.x, -pixel_size.y));
color += 2. * Texel(tex, tc + vec2(0, -pixel_size.y));
color += 1. *Texel(tex, tc + vec2(pixel_size.x, -pixel_size.y));
color += -1. * Texel(tex, tc + vec2(-pixel_size.x, pixel_size.y));
color += -2. * Texel(tex, tc + vec2(0, pixel_size.y));
color += -1. *Texel(tex, tc + vec2(pixel_size.x, pixel_size.y));
return color;
}]]
effect:send('pixel_size', {1/love.graphics.getWidth(), 1/love.graphics.getHeight()})
Code: Select all
1/9 1/9 1/9
1/9 1/9 1/9
1/9 1/9 1/9