chroma_solstice/shaders.lua

32 lines
889 B
Lua
Raw Normal View History

2015-03-14 05:36:02 -04:00
wiggle = love.graphics.newShader[[
extern number seed;
extern number amount;
int grain = 10; //higher = less, lower = more
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
vec4 effect( vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
vec4 pixel_me = Texel(texture, texture_coords );
return Texel(texture, texture_coords + (rand(texture_coords * seed) - .5) * amount);
/*
int resolution = int(12 * 1 / zoom);
vec2 final_coords = floor((resolution * texture_coords) + 0.5) / resolution;
vec4 averaged_pixel = (Texel(texture, final_coords - (1 / resolution)) + Texel(texture, final_coords)) / 2 + (rand(final_coords * seed) / grain);
averaged_pixel.a = 1;
pixel_me = Texel(texture, final_coords);
return averaged_pixel;
*/
}
]]