cntrl/assets/shaders/bloom_blur.fs

27 lines
1,000 B
GLSL

#version 330
// Separable 9-tap gaussian; uDirection is one texel on the half-res target.
in vec2 fragTexCoord;
in vec4 fragColor;
out vec4 finalColor;
uniform sampler2D texture0;
uniform vec2 uDirection;
void main()
{
const float w0 = 0.227027;
const float w1 = 0.194595;
const float w2 = 0.121622;
const float w3 = 0.054054;
const float w4 = 0.016216;
vec3 c = texture(texture0, fragTexCoord).rgb * w0;
c += (texture(texture0, fragTexCoord + uDirection).rgb
+ texture(texture0, fragTexCoord - uDirection).rgb) * w1;
c += (texture(texture0, fragTexCoord + 2.0 * uDirection).rgb
+ texture(texture0, fragTexCoord - 2.0 * uDirection).rgb) * w2;
c += (texture(texture0, fragTexCoord + 3.0 * uDirection).rgb
+ texture(texture0, fragTexCoord - 3.0 * uDirection).rgb) * w3;
c += (texture(texture0, fragTexCoord + 4.0 * uDirection).rgb
+ texture(texture0, fragTexCoord - 4.0 * uDirection).rgb) * w4;
finalColor = vec4(c, 1.0);
}