precise and fast blur of a 1024x768 image/texture

Community Forums/General Help/precise and fast blur of a 1024x768 image/texture

RemiD(Posted 2016) [#1]
Hello,

Do you know a way to create a precise and fast blur of 1024x768 image/texture ?

I have used fastext in the past and it works well but the problem is that the blur is not precise enough (only six offsets, but i want 8 offsets), see :

and also fastext does not work correctly with the last version of Blitz3d...

I have tried to code my own blur routine but with several drawimages with an offset it is too slow to draw (8 drawimages for each 1 pixel offset...), and with several textured quads with an offset the blending is not like i want (8 textured quads for each 1 pixel offset, but no way to keep all colors and only mask the black pixel without having to define the alpha value of each black texel)...

I know that the old way was to use a lower resolution texture, but the results is too imprecise and ugly imo

Any suggestions ?

Thanks,


Derron(Posted 2016) [#2]
Taken the function from there:
https://github.com/GWRon/Dig/blob/master/base.gfx.imagehelper.bmx

Results in this sample:


Use the cursor keys to adjust the blur factor

Result:



bye
Ron


RemiD(Posted 2016) [#3]
@Derron>>Thanks ! i will take a look.


Bobysait(Posted 2016) [#4]
If you use the modified version of blitz3d (the one with RenderToTexture)

you can do something like this :
it will allow to modify the alpha and the offset of the blur (and also enables a glow effect if needed)




RemiD(Posted 2016) [#5]
@Bobysait>>Thanks !


RemiD(Posted 2016) [#6]
Is there a way (with Blitz3d or directx7) to set the alpha of all pixels of the backbuffer to 0.0, then render the scene, and if the rendered pixels are colored, automatically set their alpha to 1.0, but if they are not colored (if no surface/texel is rendered for this pixel) automatically set their alpha to 0.0, then capture the pixels on the backbuffer (with their color and alpha) to a texture and preserve their alpha value ? Without having to analyze the color of each texel and having to write the alpha of each texel... (too slow)


Additionally, is there a way to create (or have access to) others texture blend modes so that if a texture is on top and a texel has an alpha of 1.0, it replaces the color (without being blended) of the pixels/texels behind it, but if it has an alpha of 0.0, the color of the next pixel/texel behind it is considered ? (similar to drawimage but with textures...)


Bobysait(Posted 2016) [#7]
What do you want to do exactly ?

I'm guessing the only way to do that is to disable ClearColor/ClearDepth from the camera

-> CameraClsMode(cam, 0,0)
but you'll have to clear manually the screen, else the renderworlds will accumulate and it will be dirty as hell (well ... I suppose Hell is a dirty place ... I might be wrong).


RemiD(Posted 2016) [#8]
I want to be able to render only a black background (or transparent background) and some surfaces in fullbright, then to use screenmeshes+screentextures to reproduce what drawimage does (draw only the pixels which have a color and not the pixels which are black 0,0,0) so that i can create a precise glow (pixel precise), but faster than with drawimage (too slow)

To analyze each texel of a 1000*625 area (on a 1024*1024 texture) to determine if it is colored or black and then set its alpha to 1.0 or 0.0 is too slow, so is there a way to have all black pixels become alpha 0.0 and all colored pixels become alpha 1.0 during the render and then be able to copyrect these pixels (with their color and alpha) to a texture (and preserve their color and alpha).

Also the different texture blend modes do not correspond to the blend that i want (same than what drawimage blend), so is there a way to write a custom texture blend mode ?

Your example is ok (similar to what sswift posted) but it is not really precise glow.