33 lines
1.3 KiB
GLSL
33 lines
1.3 KiB
GLSL
#version 330 core
|
|
// 2-Pass Dual Kawase Blur Fragment Shader (OpenGL 3.3 Core)
|
|
// u_mode == 0: 5-tap downsample; u_mode != 0: 8-tap upsample.
|
|
|
|
uniform sampler2D u_tex;
|
|
uniform vec2 u_texel_size;
|
|
uniform float u_offset;
|
|
uniform int u_mode;
|
|
|
|
in vec2 v_uv;
|
|
out vec4 o_color;
|
|
|
|
void main() {
|
|
vec2 hp = u_texel_size * 0.5 * u_offset;
|
|
if (u_mode == 0) {
|
|
vec4 sum = textureLod(u_tex, v_uv, 0.0) * 4.0;
|
|
sum += textureLod(u_tex, v_uv - hp, 0.0);
|
|
sum += textureLod(u_tex, v_uv + hp, 0.0);
|
|
sum += textureLod(u_tex, v_uv + vec2(hp.x, -hp.y), 0.0);
|
|
sum += textureLod(u_tex, v_uv - vec2(hp.x, -hp.y), 0.0);
|
|
o_color = sum * 0.125;
|
|
} else {
|
|
vec4 sum = textureLod(u_tex, v_uv + vec2(-hp.x * 2.0, 0.0), 0.0);
|
|
sum += textureLod(u_tex, v_uv + vec2(-hp.x, hp.y), 0.0) * 2.0;
|
|
sum += textureLod(u_tex, v_uv + vec2(0.0, hp.y * 2.0), 0.0);
|
|
sum += textureLod(u_tex, v_uv + vec2(hp.x, hp.y), 0.0) * 2.0;
|
|
sum += textureLod(u_tex, v_uv + vec2(hp.x * 2.0, 0.0), 0.0);
|
|
sum += textureLod(u_tex, v_uv + vec2(hp.x, -hp.y), 0.0) * 2.0;
|
|
sum += textureLod(u_tex, v_uv + vec2(0.0, -hp.y * 2.0), 0.0);
|
|
sum += textureLod(u_tex, v_uv + vec2(-hp.x, -hp.y), 0.0) * 2.0;
|
|
o_color = sum * (1.0 / 12.0);
|
|
}
|
|
}
|