Skip to content

Commit

Permalink
shaders: Make blur shaders make sense
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Shishkin <[email protected]>
  • Loading branch information
virtuoso committed Oct 13, 2024
1 parent 7b00b58 commit b601da0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 32 deletions.
24 changes: 12 additions & 12 deletions shaders/hblur.frag
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ void main()
{

FragColor = vec4(0.0);
FragColor += texture(model_tex, blur_coords[0]) * 0.0093;
FragColor += texture(model_tex, blur_coords[1]) * 0.028002;
FragColor += texture(model_tex, blur_coords[2]) * 0.065984;
FragColor += texture(model_tex, blur_coords[3]) * 0.121703;
FragColor += texture(model_tex, blur_coords[4]) * 0.175713;
FragColor += texture(model_tex, blur_coords[5]) * 0.198596;
FragColor += texture(model_tex, blur_coords[6]) * 0.175713;
FragColor += texture(model_tex, blur_coords[7]) * 0.121703;
FragColor += texture(model_tex, blur_coords[8]) * 0.065984;
FragColor += texture(model_tex, blur_coords[9]) * 0.028002;
FragColor += texture(model_tex, blur_coords[10]) * 0.0093;
}
FragColor += texture(model_tex, pass_tex + blur_coords[0]) * 0.0093;
FragColor += texture(model_tex, pass_tex + blur_coords[1]) * 0.028002;
FragColor += texture(model_tex, pass_tex + blur_coords[2]) * 0.065984;
FragColor += texture(model_tex, pass_tex + blur_coords[3]) * 0.121703;
FragColor += texture(model_tex, pass_tex + blur_coords[4]) * 0.175713;
FragColor += texture(model_tex, pass_tex + blur_coords[5]) * 0.198596;
FragColor += texture(model_tex, pass_tex + blur_coords[6]) * 0.175713;
FragColor += texture(model_tex, pass_tex + blur_coords[7]) * 0.121703;
FragColor += texture(model_tex, pass_tex + blur_coords[8]) * 0.065984;
FragColor += texture(model_tex, pass_tex + blur_coords[9]) * 0.028002;
FragColor += texture(model_tex, pass_tex + blur_coords[10]) * 0.0093;
}
7 changes: 3 additions & 4 deletions shaders/hblur.vert
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ out vec2 blur_coords[11];

void main()
{
gl_Position = /*trans * */vec4(position, 1.0);
gl_Position = trans * vec4(position, 1.0);
pass_tex = tex;
vec2 center_coords = position.xy * 0.5 + 0.5;
float pixsz = 1.0 / width;
for (int i = -5; i <= 5; i++)
blur_coords[i + 5] = center_coords + vec2(pixsz * float(i), 0.0);
}
blur_coords[i + 5] = vec2(pixsz * float(i), 0.0);
}
24 changes: 12 additions & 12 deletions shaders/vblur.frag
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ void main()
{

FragColor = vec4(0.0);
FragColor += texture(model_tex, blur_coords[0]) * 0.0093;
FragColor += texture(model_tex, blur_coords[1]) * 0.028002;
FragColor += texture(model_tex, blur_coords[2]) * 0.065984;
FragColor += texture(model_tex, blur_coords[3]) * 0.121703;
FragColor += texture(model_tex, blur_coords[4]) * 0.175713;
FragColor += texture(model_tex, blur_coords[5]) * 0.198596;
FragColor += texture(model_tex, blur_coords[6]) * 0.175713;
FragColor += texture(model_tex, blur_coords[7]) * 0.121703;
FragColor += texture(model_tex, blur_coords[8]) * 0.065984;
FragColor += texture(model_tex, blur_coords[9]) * 0.028002;
FragColor += texture(model_tex, blur_coords[10]) * 0.0093;
}
FragColor += texture(model_tex, pass_tex + blur_coords[0]) * 0.0093;
FragColor += texture(model_tex, pass_tex + blur_coords[1]) * 0.028002;
FragColor += texture(model_tex, pass_tex + blur_coords[2]) * 0.065984;
FragColor += texture(model_tex, pass_tex + blur_coords[3]) * 0.121703;
FragColor += texture(model_tex, pass_tex + blur_coords[4]) * 0.175713;
FragColor += texture(model_tex, pass_tex + blur_coords[5]) * 0.198596;
FragColor += texture(model_tex, pass_tex + blur_coords[6]) * 0.175713;
FragColor += texture(model_tex, pass_tex + blur_coords[7]) * 0.121703;
FragColor += texture(model_tex, pass_tex + blur_coords[8]) * 0.065984;
FragColor += texture(model_tex, pass_tex + blur_coords[9]) * 0.028002;
FragColor += texture(model_tex, pass_tex + blur_coords[10]) * 0.0093;
}
7 changes: 3 additions & 4 deletions shaders/vblur.vert
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ out vec2 blur_coords[11];

void main()
{
gl_Position = /*trans * */vec4(position, 1.0);
gl_Position = vec4(position, 1.0);
pass_tex = tex;
vec2 center_coords = position.xy * 0.5 + 0.5;
float pixsz = 1.0 / height;
for (int i = -5; i <= 5; i++)
blur_coords[i + 5] = center_coords + vec2(0.0, pixsz * float(i));
}
blur_coords[i + 5] = vec2(0.0, pixsz * float(i));
}

0 comments on commit b601da0

Please sign in to comment.