Sunday, December 6, 2026

ASTC Pixel Shader Deblocking with Mipmapping

Deblocking is standard in image and video compression, and it turns out to be simple to add to ASTC sampling too. The method is compatible with any ASTC encoder, but an encoder that optimizes for a simple pixel shader reconstruction filter can create far better-looking output. The video world figured this out decades ago: post-filtering (or out-of-loop filtering) vs. in-loop filtering.

On ASTC hardware (available on many billions of shipped devices, with 800 million more shipped per year that don't support BC1-7), adding mipmap-aware shader deblocking permits the usage of larger block sizes than you normally could use. There are 14 block sizes supported by the ASTC hardware's generative decoder, and once you add deblocking you'll be unlocking all of them - even up to 12x12 (0.89 bpp).

The primary goal with the deblocking shader was to preserve standard GPU hardware filtering: bilinear filtering, and mipmapping with trilinear or anisotropic filtering. So the texture fetches it uses are entirely standard - nothing special. Each is just filtered by the GPU hardware, as usual. (Anything else would be too slow/complex.)

I tried around 10 ASTC deblocking pixel shader variants before settling on this one. Being mipmap compatible and temporally stable was a crucial requirement.

There's the usual center sample. The shader then samples around the center sample 4 times (left/right/upper/lower, with the sampling distance taking into account the dominant mipmap level), and it then blends the output. The output blend depends on where the center sample falls relative to the block edges: samples inside each texture block have no filtering at all. The transition between edge filtering and no filtering is smooth. At block edges the low-pass filter is at maximum strength.

The mipmap part computes the dominant mipmap level that will influence the output most, which is easy using shader derivative instructions. The ASTC WxH block size in texels must be provided to the shader in constants, so it knows where it's sampling within the block footprint of the dominant mipmap level.

I really wanted to make the block edge filtering adaptive, to avoid filtering away real edges at block boundaries, but I couldn't find a way to make that temporally stable as an object rotates/scales in 3D. It was also too complex.

This filter could easily be added by the IHVs directly to the GPU texture sampling hardware.

Shader:

https://github.com/BinomialLLC/basis_universal/blob/master/shader_deblocking_glfw/bin/shader.glsl

GLSL sample:

https://github.com/BinomialLLC/basis_universal/tree/master/shader_deblocking_glfw

D3D11 sample:

https://github.com/BinomialLLC/basis_universal/tree/master/shader_deblocking_d3d11

Mathematical analysis of the Basis Universal ASTC deblocking shader:

https://chatgpt.com/share/6b158d07-0368-83e8-b79a-53fda74bed5c


Sample GLSL Deblocking Shader


#vertex

#version 330 core


layout(location = 0) in vec3 aPos;

layout(location = 1) in vec2 aUV;

uniform mat4 mvp;


out vec2 vUV;


void main() {

    vUV = aUV;

    gl_Position = mvp * vec4(aPos, 1.0);

}


#fragment

#version 330 core


uniform sampler2D tex;

uniform vec4 texSize;  // Base mip dimensions (mip 0) in xy, zw=ASTC block size of texture

uniform float maxLod;  // = number_of_mip_levels - 1

uniform vec4 const0;   // User constant 0 (keys 1-4 toggle x,y,z,w)

uniform vec4 const1;   // User constant 1 (keys 5-8 toggle x,y,z,w)


in vec2 vUV;

out vec4 fragColor;


void main() 

{

    // Note: Could use textureQueryLod() but it's not supported in WebGL. textureSize() is in WebGL 2.0 however.

    const vec3 LUMA = vec3(0.299, 0.587, 0.114);


    vec2 texDim = vec2(texSize.x, texSize.y);

    vec2 blockSize = vec2(texSize.z, texSize.w);

    

    vec2 du = dFdx(vUV);

    vec2 dv = dFdy(vUV);

    float rho = max(length(du * texSize.xy), length(dv * texSize.xy));

    float lod = clamp(log2(max(rho, 1e-8)), 0.0, maxLod); // lod index

    float mipScale = exp2(floor(lod + .5)); // 2^lod mipmap scale, snaps to dominant mipmap, 1=mip0, 2=mip1, 4=mip2, etc.

        

    vec2 texelStep = mipScale / texDim; // how to step one texel in effective mip space

    vec2 texelPos = (vUV * texDim) / mipScale; // the physical texel coord in effective mip space

    vec2 blockPos = mod(texelPos, blockSize); // the block offset in texels

            

    vec3 color;

    color = texture(tex, vUV).rgb;


    // Keep these fetches outside non-uniform control flow: texture() uses implicit

    // derivatives for LOD, which are undefined when neighboring fragments take

    // different branches. Use explicit LOD so edgeWeight can safely go to zero.

    vec3 l1 = texture(tex, vUV - vec2(texelStep.x, 0.0)).rgb;

    vec3 r1 = texture(tex, vUV + vec2(texelStep.x, 0.0)).rgb;

                    

    vec3 u1 = texture(tex, vUV - vec2(0.0, texelStep.y)).rgb;

    vec3 d1 = texture(tex, vUV + vec2(0.0, texelStep.y)).rgb;


    if (const0.x > 0.5) 

    {

        const float falloff = 1.5;

        

        float leftProx   = 1.0 - clamp(blockPos.x / falloff, 0.0, 1.0);

        float rightProx  = 1.0 - clamp((blockSize.x - blockPos.x) / falloff, 0.0, 1.0);

        float topProx    = 1.0 - clamp(blockPos.y / falloff, 0.0, 1.0);

        float bottomProx = 1.0 - clamp((blockSize.y - blockPos.y) / falloff, 0.0, 1.0);


        float horizWeight = max(leftProx, rightProx);

        float vertWeight = max(topProx, bottomProx);

        float edgeWeight = max(horizWeight, vertWeight); // overall proximity

        

        if (edgeWeight > 0.0)

        {                       

            vec3 c0 = color;

                                    

            vec3 filteredH = (l1 + c0 + r1) * (1.0/3.0);

            vec3 filteredV = (u1 + c0 + d1) * (1.0/3.0);

        

            float strengthH = horizWeight;

            float strengthV = vertWeight;


            vec3 horizColor = mix(c0, filteredH, strengthH);

            vec3 vertColor  = mix(c0, filteredV, strengthV);


            float totalW = strengthH + strengthV;

            if (totalW > 0.0)

                color = (horizColor * strengthH + vertColor * strengthV) / totalW;

        }


        // block edge vis

        if (const0.y > 0.5)         

        {

            color = vec3(edgeWeight, edgeWeight, edgeWeight);

        }

    }

            

    fragColor = vec4(color, 1.0);

}

Saturday, December 5, 2026

Transforms: Massive Bitrate Unlock in GPU Texture Supercompression

There is a reason JPEG and video uses DCT.

Without transform coding LZ-RDO methods for GPU texture supercompression (which I innovated over a decade ago, in the "crunch" library) are fundamentally bottlenecked. Transforms (DCT etc.) unlock another rate vs. distortion axis, complementary to RDO. The method is based off scientific work at NASA Ames that resulted in improvements to JPEG. 

LZ-RDO wastes roughly half the bits it sends (i.e. half the user's download time - or more) as unstructured noise, to save computations that can be done locally during the download or in the background on cheap CPU's or on the GPU. 

I suspect the video game industry will figure this out in ~3-5 years. The first mover will have a "funnel" advantage. Outside of games we're already using XUASTC LDR on petascale deployment use cases.

I shouldn't be too loud about this, although it's entirely obvious.

Basis Universal v3.0 performance/ratio improvements at a glance

Shipping on GitHub in Jan. 2027.  Click to zoom:


Friday, December 4, 2026

Basis Universal v3.0: XUASTC 4x4, 8x8 and 12x12 arithmetic R-D graph

See this red line? This is what AI (via "astcg" - our next ASTC encoder) gives Binomial's XUASTC LDR codec: higher quality at same bitrate, or lower bitrate at the same quality. As the frontier models get better, our codecs get better.

At 8x8: Roughly ~7–11% less bitrate vs. basisu public across Q40–Q80, up to -13% to -16% on RGBA around Q90, while encoding ~3x faster.

Note this is not factoring in LRDO, which is also new to our XUASTC encoders and is supported by all three profiles (Zstd, hybrid, and arithmetic). LRDO results in compounding gains.

8x8

12x12

4x4


Monday, November 30, 2026

astcg: our first AI authored ASTC LDR encoder

Our new ASTC encoder "astcg" (G=Gemini), in XUASTC LDR mode, is working inside of Basis Universal now using WASM SIMD. It's 100% authored by Neon/Hydrogen, using techniques I developed earlier this year. It'll be shipped in Jan. 2027, in Basis Universal v3.0. It was going to be v2.6, but with all the improvements/features coming, we decided on v3.0.

The next step is to wire astcg up to plain ASTC/LZRDO ASTC outputs, too. This is now my 3rd full ASTC LDR encoder. 

I can keep improving and refining this over time as the frontier models keep improving, relentlessly for years.

Screenshot: supercompressed ASTC 12x12 (XUASTC LDR arithmetic profile, threaded transcoding of each row strip, WASM SIMD IDCT), 0.374 bpp, in-loop deblocking (using a tiny pixel shader for filtered reconstruction).



Monday, November 9, 2026

Basis Universal v2.6 update

basisu_pack: a new command line tool is being added to the Basis Universal open source library, shipping in Jan. 2027. Real-time, high quality GPU texture format encoders for any platform, for virtually any GPU texture format: LDR, HDR, BC1-7, ASTC (all 14 block sizes for LDR, 2 block sizes for HDR), ETC1/2, PVRTC1 etc. - all using our own encoding tech. It writes .DDS, .KTX, .KTX2, and .ASTC.

We have the real-time analytical encoders (for transcoding purposes), so now we're going to expose them via API's and tooling. They don't need SIMD, yet many of them are faster than other older search-based SIMD encoder designs.

Also coming: Official Python wheels for several platforms, transcoding performance increases, and large XUASTC compression ratio improvements.

Our CLI's are shipped as both native or as secure WASM WASI executables.