jgroenendaal wrote: ↑Wed 15 Jan 2025, 18:07
Your example also shows another thing that I pessonally really like, the
gfxBoxBlurNxN you did in the example much more than the
GaussianBlur3x3 I used.
Actually I used both (see code below) but I don't think the Gaussian Blur added much. The Box Blur can do a lot of blurring very quickly,
but it's not at all realistic because in the real world the aperture won't be square! So if a realistic blur is important the Box Blur doesn't fit the bill.
Of course if you have the luxury of doing the blurring accurately, but slowly, offline (using Photoshop or similar), which you probably do in this case, the resulting quality will be better. But sometimes it has to be done in real time and compromises are necessary.
Code: Select all
VDU 23,22,720;720;8,16,16,0
INSTALL @lib$ + "aagfxlib"
INSTALL @lib$ + "gfxlib"
PROC_gfxInit
REM Load original texture (e.g. 3000 x 2000)
dice%% = FN_gfxLoadTexture(@dir$ + "virtual.jpg", FALSE)
REM Define mask:
DIM x(12), y(12)
x() = 400, 1040, 1040, 930, 930, 1040, 1040, 400, 400, 510, 510, 400, 400
y() = 100, 100, 1060, 1060, 1110, 1110, 1340, 1340, 1110, 1110, 1060, 1060, 100
REM Blur:
PROC_gfxPlotScale(dice%%, 1080, 720, -180, 0)
PROC_gfxGaussianBlur3x3(720, 720, 0, 0)
PROC_gfxBoxBlurNxN(720, 720, 0, 0, 32)
REM Copy blurred image to texture:
blur%% = FN_gfxCreateTexture(720, 720)
PROC_gfxCopy(blur%%, 720, 720, 0, 0)
REM Mask blurred image::
mask%% = FN_gfxCreateTexture(720, 720)
PROC_gfxSaveAndSetDispVars(g{}, mask%%)
PROC_aapolygon(12, x(), y(), &FF000000)
PROC_gfxReversePlotScale(blur%%, 720, 720, 0, 0)
PROC_gfxRestoreDispVars(g{})
REM Combine and add border:
PROC_gfxPlotScale(dice%%, 1080, 720, -180, 0)
PROC_gfxPlotScale(mask%%, 720, 720, 0, 0)
PROC_aapolyline(13, x(), y(), 4, &FFB0B0B0, 0)
REM Destroy temporary textures:
PROC_gfxDestroyTexture(blur%%)
PROC_gfxDestroyTexture(mask%%)