With UPBGE 0.1.4 introducing Mipmapping for the bgl_renderedTexture, this makes blurring much easier and more efficient.
Before (Standard bloom with 4 samples):
After (new filter with 4 samples):
Downsides to using this method:
-Slightly displaced to the top left due to mipmapping.
-Can cause banding when incorrect settings are used.
uniform sampler2D bgl_RenderedTexture;
float blur_amount = 2.0;
float threshold = 0.5;
int blur_sample = 4;
float blur_size = 0.003;
int x=0;
int y=0;
vec4 brightness(vec4 current_color){
current_color = max(current_color-threshold, 0.0);
return current_color;
}
void main()
{
vec4 new_color = vec4(0);
for (x=-blur_sample; x <= blur_sample; x++){
for (y=-blur_sample; y<= blur_sample; y++){
vec2 offset = vec2(x,y) * blur_size;
new_color += brightness(texture2D(bgl_RenderedTexture, gl_TexCoord[0].st + offset, blur_amount));
}
}
new_color /= ((blur_sample*2)+1)*((blur_sample*2)+1);
gl_FragColor = texture2D(bgl_RenderedTexture, gl_TexCoord[0].st, 0.0)+new_color;
}
I will probably attempt using the more efficient kawase blur algorithm when I get some time, to make it run even better.