ABoxBlur
[GameMaker] Arbitrarily sized box-blur for any pixel.
This library provides following function, which can be used to apply box-blur;
ABoxBlur(_dst, _src, _blur, _strength, _fallback);
- dst is destination surface
- src is source surface
- blur-mask is surface, which tells how strongly blur should be applied.
- strength is multiplier how strongly blur-mask is applied.
- fallback is whether use compatibility rgba8unorm-version (no float-textures). Default is false.
This asset works by applying parallel prefix sum in two axis to generate summed-area table. This table is sampled at the corners of desired box-blur area to calculate the sum of the area. As area is known, it can be use to divide the sum, calculating the average, which is the box-blur.
The parallel prefix scan is implemented in Hillis-Steele style, which is easy but work-inefficient approach. Blelloch would be better option, but it's harder to implement with fragment shaders (but not impossible).
The asset currently always recreates the sum-table. This in some cases is not necessary (when source image doesn't change), and as most of the work is done for creating the sum-table, it would be much more performant if it didn't do at those cases. As blur mask and sum-table are separate, you could change blur-mask without recreating sum-table.
Although asset only does box-blur, you could technically emulate different shapes by taking more boxes. Getting sum of area requires 4 sum-table samples, so with three overlapping boxes (12 samples) you could already do rough approximates of other blurs.
Note! Not mobile browser friendly (most likely glitches).
Download
Click download now to get access to the following files:









Leave a comment
Log in with itch.io to leave a comment.