Modern-Apps.git
Publicgit clone https://git.maproj.org/Modern-Apps.gitModern-Apps.git / games / voxels / src / main / rust / shaders / blur.frag
blur.frag18 lines · 690 BRaw
| 1 | #version 450 |
| 2 | // Separable 5-tap Gaussian blur. `pc.param.xy` = uv step along the blur axis. |
| 3 | layout(location=0) in vec2 vUv; |
| 4 | layout(binding=0) uniform sampler2D src; |
| 5 | layout(binding=1) uniform sampler2D unused; |
| 6 | layout(push_constant) uniform PC { vec4 param; } pc; |
| 7 | layout(location=0) out vec4 outColor; |
| 8 | void main() { |
| 9 | vec2 d = pc.param.xy; |
| 10 | vec3 s = texture(src, vUv).rgb * 0.227027; |
| 11 | vec2 o1 = d * 1.3846153846; |
| 12 | vec2 o2 = d * 3.2307692308; |
| 13 | s += texture(src, vUv + o1).rgb * 0.3162162162; |
| 14 | s += texture(src, vUv - o1).rgb * 0.3162162162; |
| 15 | s += texture(src, vUv + o2).rgb * 0.0702702703; |
| 16 | s += texture(src, vUv - o2).rgb * 0.0702702703; |
| 17 | outColor = vec4(s, 1.0); |
| 18 | } |