I’m trying to implement bloom, and it’s pretty easy, but there’s one problem.
It’s working, but it looks like this from afar:
See those weird blobs? I’m not downsampling, but I think it’s a resolution issue. It gets worse as I move further away.
Here’s my vertical blur shader:
#version 400 core
in vec2 passTextureCoords;
out vec4 outColour;
uniform sampler2D textureSampler;
uniform float weights[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
void main(void) {
vec2 texelSize = 1.0/textureSize(textureSampler, 0);
vec4 colour = texture(textureSampler, passTextureCoords) * weights[0];
for(int i = 1; i < 5; ++i){
colour += texture(textureSampler, passTextureCoords + vec2(0, texelSize.y * i)) * weights[i];
colour += texture(textureSampler, passTextureCoords - vec2(0, texelSize.y * i)) * weights[i];
}
outColour = colour;
}
Here’s my horizontal blur shader:
#version 400 core
in vec2 passTextureCoords;
out vec4 outColour;
uniform sampler2D textureSampler;
uniform float weights[5] = float[] (0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
void main(void) {
vec2 texelSize = 1.0/textureSize(textureSampler, 0);
vec4 colour = texture(textureSampler, passTextureCoords) * weights[0];
for(int i = 1; i < 5; ++i){
colour += texture(textureSampler, passTextureCoords + vec2(texelSize.x * i, 0)) * weights[i];
colour += texture(textureSampler, passTextureCoords - vec2(texelSize.x * i, 0)) * weights[i];
}
outColour = colour;
}
Here’s what it’s supposed to look like:
As you can see, there aren’t any weird blobs in this image.
This is my second attempt to implement bloom. I had the same problem the last time, and since it’s such an awesome effect, I’d love to be able to implement it successfully. Thanks.