[UPBGE] New Mipmap bloom filter!


(Thatimster) #1

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.


(youle) #2

@Thatimster: Hi, Thanks this looks cool :slight_smile: For banding issue, I think you can use HDR option in upbge render panel (half is generally enough. HDR costs performances. It correspond to openGL RGBA_16F in openGL)

EDIT: oh, ok I thought about another kind of banding effect that happens sometimes with bloom filters.


(Nicholas_A) #3

How do you recommend I start learning to make filters?


(Thatimster) #4

Thanks :smiley: its mainly a mipmapping issue because of the lowered resolution. Using HDR just seems to increase color but doesn’t appear to affect the resolution.

Learn C, it makes understanding everything and writing new code so much easier!


(lopas) #5

i got this flickering issue due to the lack of “valid” pixels on mipmap levels, someone knows some trick for getting better results?


(Nick Manchul) #6
  • and I have this shader does not work, probably it’s because there are no proprietary drivers - AMD.

Of course, this you laid out for non-commercial use.

Thatimster - forgive me for an immodest question - 3d graphics, this is your hobby between work, you’re a civil servant in a cap - like I was not mistaken? Simply, as an example, I can be a cop, and as a hobby is engaged in graphics - although I’m not a cop.


(BluePrintRandom) #7

upbge are you using upbge recent build?


(Akira_San) #8

and I have this shader does not work, probably it’s because there are no proprietary drivers - AMD.

lets see your AMD drvs? - blender - help - save system log.


(Nick Manchul) #9
  • apt-cache show xserver-xorg-video-radeon

Package: xserver-xorg-video-radeonSource: xserver-xorg-video-ati (1:7.8.0-1)
Version: 1:7.8.0-1+b1
Installed-Size: 825
Maintainer: Debian X Strike Force <[email protected]>
Architecture: amd64
Provides: xorg-driver-video
Depends: libc6 (>= 2.17), libdrm-radeon1 (>= 2.4.39), libudev1 (>= 183), xorg-video-abi-23, xserver-xorg-core (>= 2:1.18.99.901)
Suggests: firmware-amd-graphics
Description-en: X.Org X server – AMD/ATI Radeon display driver
This package provides the ‘radeon’ driver for the AMD/ATI cards. The
following chips should be supported: R100, RV100, RS100, RV200, RS200,
RS250, R200, RV250, RV280, RS300, RS350, RS400/RS480, R300, R350, R360,
RV350, RV360, RV370, RV380, RV410, R420, R423/R430, R480/R481,
RV505/RV515/RV516/RV550, R520, RV530/RV560, RV570/R580,
RS600/RS690/RS740, R600, RV610/RV630, RV620/RV635, RV670, RS780/RS880,
RV710/RV730, RV740/RV770/RV790, CEDAR, REDWOOD, JUNIPER, CYPRESS,
HEMLOCK, PALM, SUMO/SUMO2, BARTS, TURKS, CAICOS, CAYMAN, ARUBA, TAHITI,
PITCAIRN, VERDE, OLAND, HAINAN, BONAIRE, KABINI, MULLINS, KAVERI, HAWAII.
.
More information about X.Org can be found at:
<URL:http://www.X.org>
.
This package is built from the X.org xf86-video-ati driver module.
Description-md5: f0dc7040ebe20189598467915db9b2e1
Homepage: https://wiki.freedesktop.org/xorg/RadeonFeature/
Tag: admin::hardware, hardware::video, implemented-in::c, role::plugin,
use::driver, x11::xserver
Section: x11
Priority: optional
Filename: pool/main/x/xserver-xorg-video-ati/xserver-xorg-video-radeon_7.8.0-1+b1_amd64.deb
Size: 463150
MD5sum: faa80babd8855cdb37b7979f7631d070
SHA256: 13d8155a08801dad08a67dff8cb2f451aff199723e3ec22f1eab09039f6a99b6

  • glxinfo |grep -i opengl

OpenGL vendor string: X.Org
OpenGL renderer string: Gallium 0.4 on AMD KABINI (DRM 2.49.0 / 4.9.0-4-amd64, LLVM 3.9.1)
OpenGL core profile version string: 4.3 (Core Profile) Mesa 13.0.6
OpenGL core profile shading language version string: 4.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 13.0.6
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.1 Mesa 13.0.6
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
OpenGL ES profile extensions:

  • everything is normal, these are standard open drivers - even parallax does not work for them. But if you deliver from AMD (fresh), everything will be fine…
    There are no errors in the console.

(lopas) #10

i played a little with my previous algorithm and the result seems a bit better


(Nick Manchul) #11
  • I’m sorry, but is the open shading language (osl), is it the C language?

(lopas) #12

it is glsl whose syntax is practically the same as c


(Nick Manchul) #13
  • I understand, I basically thought so.

(Akira_San) #14

@lopas
Great bloom filter. You gonna share?
@Nick Manchul
Well for Linux you have OGL 3 and glsl 1.3, so it should work. But the mesa is too old. You still should see an error message in the console.


(Nick Manchul) #15
  • it’s Debian, here everything is old, but time-tested - Deban + server = Wi…ws out.
  • There are no errors in the console. The console prescribes the errors of the shader, not the driver’s faults.

(RyceKaeks) #16

Just to let you know this works with blender 2.79


(Nick Manchul) #17

Thatimster

  • Hey man! Ask how, then, in John Hamilton, who has better intelligence - in New Zealand or Australia - you’re friends snap? I’m just ashamed of you talking about this.

(OTO) #18

Dear user Nick Manchui, could you edit your last post, and make it more precise - and return his sense to the original topic, maybe - or delete it?
Bye


(Nick Manchul) #19
  • Hi OTO, dear forum administrator. At the beginning I apologize for my disobedience, but I will not delete or change anything.
    For these two comrades everything is clear throughout the text, Gleb Alexandrov can confirm this … like Wonder Woman.
    For example, Tatimster wears a military uniform (like black), but when John Hamilton comes, he shows him a fist … and Gleb they show both their fists. But before a certain lady they fall on their knees - mos … knows who to bet on.
    Just to each his own - who is a hobby, who collects information and mentally battles.

(Tattorack) #20

@Thatimster
This is a really nice looking bloom you got there:



I achieved that by passing the filter twice on the camera. I’m wondering if its possible to edit the bloom intensity in the script instead of passing it twice.
Also, is there a way to exclude certain objects from getting bloom?