I achieved similar result to theirs. First, the target texture for mip generation is base texture size + two margins, each equals 0.125 of base size.
Then during generation of base mip level, there are two cases:
- inside the square, then just sample original texture,
- beyond the central square, then blur the original texture with varying sigma, which depends on distance of current fragCoord from central square borders. While blurring texcoord is clamped to central square borders.
How to compute distance: https://gamedev.stackexchange.com/a/44496/91268
Gaussian one pass blur I used: https://www.shadertoy.com/view/XdfGDH
Here are code fragments:
vec2 coord = gl_FragCoord.xy;
vec2 minCorner = margin;
vec2 maxCorner = filteredMipRes - margin;
if(insideBox(coord, minCorner, maxCorner) > 0.5)
fragColor = textureLod(sourceTexture, tc, 0.0).rgb;
vec2 center = filteredMipRes / 2.0;
vec2 d = max(abs(coord - center) - baseTextureRes / 2.0, vec2(0.0));
float dist = sqrt(d.x * d.x + d.y * d.y);
sigma = max(dist*2.0, 0.5);
fragColor = blur(sigma);
Rest of mipmaps are just equally gaussian blurred, each based on one level higher mip.