1#version 450 2 3layout(push_constant) uniform Push 4{ 5 vec4 SourceSize; 6 vec4 OriginalSize; 7 vec4 OutputSize; 8 uint FrameCount; 9} params; 10 11layout(std140, set = 0, binding = 0) uniform UBO 12{ 13 mat4 MVP; 14} global; 15 16#include "blur_params.inc" 17 18#define kernel(x) exp(-GLOW_FALLOFF * (x) * (x)) 19 20#pragma stage vertex 21layout(location = 0) in vec4 Position; 22layout(location = 1) in vec2 TexCoord; 23layout(location = 0) out vec2 vTexCoord; 24 25void main() 26{ 27 gl_Position = global.MVP * Position; 28 vTexCoord = TexCoord; 29} 30 31#pragma stage fragment 32layout(location = 0) in vec2 vTexCoord; 33layout(location = 0) out vec4 FragColor; 34layout(set = 0, binding = 2) uniform sampler2D Source; 35 36void main() 37{ 38 vec3 col = vec3(0.0); 39 float dx = params.SourceSize.z; 40 41 float k_total = 0.0; 42 for (int i = -TAPS; i <= TAPS; i++) 43 { 44 float k = kernel(i); 45 k_total += k; 46 col += k * texture(Source, vTexCoord + vec2(float(i) * dx, 0.0)).rgb; 47 } 48 FragColor = vec4(col / k_total, 1.0); 49} 50