Pixel-Composer/shaders/sh_blur_directional/sh_blur_directional.fsh
2022-01-13 11:24:03 +07:00

28 lines
584 B
GLSL

//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float strength;
uniform float direction;
vec4 dirBlur(vec2 angle) {
vec4 acc = vec4(0.);
const float delta = 2.0 / 32.;
for(float i = -1.0; i <= 1.0; i += delta) {
vec4 col = texture2D( gm_BaseTexture, v_vTexcoord - vec2(angle.x * i, angle.y * i));
acc += col;
}
acc.rgb *= 0.5;
return acc * delta;
}
void main() {
float r = radians(direction);
vec2 dirr = vec2(sin(r), cos(r));
gl_FragColor = dirBlur(strength * dirr);
}