light_world.lua/lib/shaders/postshaders/scanlines.glsl

34 lines
1.2 KiB
Plaintext
Raw Normal View History

2014-09-26 17:42:00 +00:00
extern vec2 screen = vec2(800.0, 600.0);
2014-04-08 17:45:21 +00:00
extern float strength = 2.0;
2014-03-28 02:32:32 +00:00
extern float time = 0.0;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 pixel_coords){
2014-09-26 17:42:00 +00:00
vec2 pSize = 1.0 / screen;
2014-03-28 02:32:32 +00:00
float brightness = 1.0;
2014-04-08 17:45:21 +00:00
float offsetX = sin(texture_coords.y * 10.0 + time * strength) * pSize.x;
float corner = 500.0;
2014-03-28 02:32:32 +00:00
if(texture_coords.x < 0.5) {
if(texture_coords.y < 0.5) {
2014-04-08 17:45:21 +00:00
brightness = min(texture_coords.x * texture_coords.y * corner, 1.0);
2014-03-28 02:32:32 +00:00
} else {
2014-04-08 17:45:21 +00:00
brightness = min(texture_coords.x * (1.0 - texture_coords.y) * corner, 1.0);
2014-03-28 02:32:32 +00:00
}
} else {
if(texture_coords.y < 0.5) {
2014-04-08 17:45:21 +00:00
brightness = min((1.0 - texture_coords.x) * texture_coords.y * corner, 1.0);
2014-03-28 02:32:32 +00:00
} else {
2014-04-08 17:45:21 +00:00
brightness = min((1.0 - texture_coords.x) * (1.0 - texture_coords.y) * corner, 1.0);
2014-03-28 02:32:32 +00:00
}
}
float red = Texel(texture, vec2(texture_coords.x + offsetX, texture_coords.y + pSize.y * 0.5)).r;
float green = Texel(texture, vec2(texture_coords.x + offsetX, texture_coords.y - pSize.y * 0.5)).g;
float blue = Texel(texture, vec2(texture_coords.x + offsetX, texture_coords.y)).b;
if(fract(gl_FragCoord.y * (0.5*4.0/3.0)) > 0.5) {
2014-03-28 02:32:32 +00:00
return vec4(vec3(red, green, blue) * brightness, 1.0);
} else {
return vec4(vec3(red * 0.75, green * 0.75, blue * 0.75) * brightness, 1.0);
}
2014-09-26 17:42:00 +00:00
}