Skip to content

By PromptFission2 min read

AF-NTC squeezes five material maps into a tiny shader network, tuned over 60 automated trials

A WebGPU texture codec reports beating 16x anisotropic BC7 at 22 percent of the bytes on four test materials. On one of them it is slightly worse.


A game material is a stack of textures: colour, roughness, metalness, a normal map, an occlusion map. AF-NTC, from GitHub user wrong-nebula, replaces that stack with small learned images and a neural network that runs in the pixel shader and reconstructs all five maps at once. The author reports it beats the standard compressed format at under a quarter of the size. The other story is how the design was reached: 60 timed trials by what the repo calls an autonomous research loop, scored by a judge it was not allowed to touch.

The repo is a single commit from November 26, from the same account as procgen-hy4.

How it works

Each material is stored as two grids of learned numbers: 512x512 with four channels and 1024x1024 with one.

To shade a pixel, the shader reads the grids six times, four from the first and two from the second, and feeds the results to a network of three layers, 48 units wide, compiled to half-precision shader code for Three.js and WebGPU. Out come the five maps.

The hard case for textures is the grazing angle, a floor stretching to the horizon, where one screen pixel covers a long thin strip of texture. Conventional 16x anisotropic filtering handles that by reading many samples: 80 across five maps, by the README’s count. Here the positions and weights of the six reads are learned per material, and the network is told the shape and direction of the pixel’s footprint.

Sixty generations and a locked judge

The theory document describes 60 trials on Colab T4 GPUs, from a baseline to a final “Gen 59”. The ground truth comes from 4096x4096 Poly Haven materials. A hash file is said to show the scoring oracle went unmodified throughout. The document does not say which model or tooling ran the loop.

It does list what failed: a sine-activated network, 5-bit and 8-bit integer variants, and one decoder shared across materials. Several late trials were disqualified for going over a 25 percent budget, one of them with a better grazing-angle score than the winner.

The author’s numbers, for four held-out materials against 1K BC7 with 16x anisotropic filtering:

BC7 16x aniso AF-NTC Gen 59
Grazing-angle PSNR 46.36 dB 46.84 dB
Normal-map error 1.87 degrees 1.61 degrees
Encoded size 6,826.8 KB 1,525.2 KB
Texture reads per pixel 80 6

Read the per-material rows before the averages. The grazing gain comes from bronze and slate. On knitted carpet it is a tie, and on herringbone parquet AF-NTC is slightly worse, both at grazing angles and head on. Four materials is a small test, and it is not clear to us how per-material learned sampling squares with calling the materials held out. Speed, 61 frames per second, was measured on one Apple M1. We found no independent reproduction.

Try it yourself

There is a live demo that needs a WebGPU browser, and the repo runs locally with npm run dev. Code and models are MIT licensed, and the test textures are CC0.

We have not run the demo or the code; the demo site was not reachable from our build machine. This is based on the README and the theory document.