UPBGE Bloom Shader

is it printing anything in the console?


I make a scene using the bloom script.
I create a logic bricks by clicking “space” key the scene will restart.
I click “P” to start the scene, the bloom script works perfectly.
When the scene restarts by clicking spacekey the script bloom no longer works.

so this sounds like a GLSL issue / not getting the buffers again when you restart

it could be I am bad at glsl or a deeper structural issue.

do you think you could do

storedData = []
for object in scene.objects:
    if 'Tracked' in objects:
       props = []
       for prop in object.getPropertyNames:
            props.append( prop, object[prop] )
       storeData.append( (object.name, object.worldTransform, props))

#using unique names is quite handy
and store data about all the objects in the scene and use this to ‘reset’ in py?

The bloom shader script seems to break on scene restart, like Adamantil1 said.
The console says -
SystemError: Blender Game Engine data has not been freed, cannot use this python variable.

Usually I’d be able to fix this issue by enabling continuous reload on the python module, but then I run into a problem with the “shader module”?
I have a screenshot of the console here.

Any idea how to fix this?

Actuators->Game->Start game from file.

Very simple and solved … thanks

To better control what blooms:
simply disable/comment/delete that jodieReinhardTonemap thing in _image.fs(lines 10-15 and, 45),
set colorRange to 1.0,
enable HDR Half (for better performance).

Than you will be able to control what blooms by taking the color values of objects/ materials/ textures to go over 1.0 just like in eevee. Without needing Color Correcition. ^^)


uniform float bgl_RenderedTextureWidth;
uniform float bgl_RenderedTextureHeight;
uniform sampler2D bgl_RenderedTexture;

vec2 iResolution = vec2(bgl_RenderedTextureWidth, bgl_RenderedTextureHeight); // viewport resolution (in pixels)
uniform sampler2D iChannel0; //! buffer[xbuf: 1, wrap: GL_CLAMP_TO_EDGE, mipmap: false, filter: GL_NEAREST]

#define colorRange 1.0

//vec3 jodieReinhardTonemap(vec3 c){
//    float l = dot(c, vec3(0.2126, 0.7152, 0.0722));
//    vec3 tc = c / (c + 8.0);

//    return mix(c / (l + 80.0), tc, 0.55);

vec3 bloomTile(float lod, vec2 offset, vec2 uv){
    return texture(iChannel0, uv * exp2(-lod) + offset).rgb;

vec3 getBloom(vec2 uv){

    vec3 blur = vec3(0.0);

    blur = pow(bloomTile(2., vec2(0.0,0.0), uv),vec3(2.2)) * 0.32 + blur;
    blur = pow(bloomTile(3., vec2(0.3,0.0), uv),vec3(2.2)) * 0.16 + blur;
    blur = pow(bloomTile(4., vec2(0.0,0.3), uv),vec3(2.2)) * 0.08 + blur;
    blur = pow(bloomTile(5., vec2(0.1,0.3), uv),vec3(2.2)) * 0.04 + blur;
    blur = pow(bloomTile(6., vec2(0.2,0.3), uv),vec3(2.2)) * 0.04 + blur;

    return blur * colorRange;

void mainImage( out vec4 fragColor, in vec2 fragCoord )
	vec2 uv = fragCoord.xy / iResolution.xy;
    vec3 color = pow(texture(bgl_RenderedTexture, uv).rgb * colorRange, vec3(2.2));
//    color = pow(color, vec3(2.2));
    color += pow(getBloom(uv), vec3(3.5));
    color = pow(color, vec3(1.0 / 4.5));
    color = max(vec3(0.0), color-0.0);
//    color = jodieReinhardTonemap(color);
	fragColor = vec4(color,1.0);

void main() {
    vec4 color = vec4(0.0, 0.0, 0.0, 1.0);
    mainImage(color, gl_FragCoord.xy);

    gl_FragColor = color;

edit: the line =~ 40 is also useless. => color = pow(color, vec3(2.2));



I have to port this to eevee soon (when aov hit eevee)

Then I will do the temporal bloom buffer shader again (where you can choose not only what blooms but what color / animate the bloom buffer)

is that not possible with the default shader in 3.0?
played a bit with it and first thing i tried was the bloom shader.

but that was it lol, did not actually go deeper into it. and no clue if those options can be called from a script.

What is the point of temporal bloom? The nice trail effect or to reduce flickering?

because i found a simpler solution to flickering.

And what is aov? something related to deferred rendering?

I am trying to imitate eevee bloom in the 2.5.0
without using render attachments.

my attempt to TheFinalBloom.blend (96.6 KB)


so currently the object can emit color / bloom that color

my buffer bloom can glow blue (emission) and bloom red (glow)

and yeah the temporal thing helps with popping, and can also be cranked way up yielding ‘streaks’ from fast moving blooming objects.

this is the patch I am waiting on being merged - https://developer.blender.org/D7010
AOV = render attachments = “arbitrary output values”

1 Like

A weapon effect glow. It never worked out, when i tried the upbge last year.

I wrote it… you have to know how to use it.

you need a bloom buffer (in render tab / attachments add 1 ‘custom’ )

you need the scripts attached to the scene(in camera typically)

and you need the objects to use attachments


1 Like

I mean, when I tried this upbge it didn’t work with my blend files. Nice work though.

yeah, nice work!

i modified it from the ‘Bloom2.blend’ in the first post so it works in some older versions
that does not have render attachments branch(0.2.4).

the file i uploaded don’t need the objects to use attachments. With hdr enabled pixel with energy higher than 1.0 (white) naturally blooms, just like eevee.

To port your projects to Upbge you may have to adapt the files and scripts.

To implement this specific shader, you need to import the modules and define the logic bricks exactly as they are in the original, even their names.

buffer_bloom_temporal_4b.blend (917.1 KB)

someone informed my my test file is not working for them - here is a update

edit - the upload was bugging


it didn’t work for me either in the past when i was using 0.2.4 branch with no attachments.

But this changed when i updated to 0.2.5. So may be the version their using.

Now, i can’t download your update. :roll_eyes: :worried:

@Murilo_Hilas - fixed I think -