Source
- URL: https://x.com/SebAaltonen/status/1320266867852922880
- Author: Sebastian Aaltonen (@SebAaltonen)
- Posted: 2020-10-25 07:32:05
Thread
1/ @SebAaltonen
Implemented a simple linear estimator for distance field value. Stored difference to this estimate as pre-process step and zlib compressed it…
Results:
Uncompressed = 926 MB
zlib = 552 MB (59%)
zlib with pre-process = 129 MB (14%)
Similar trick works for heightmap compression
2/ @SebAaltonen
When compressing SDF data, you can use the eikonal equation as the estimator instead of a linear estimate. This is better. Didn’t yet implement it.
https://en.wikipedia.org/wiki/Eikonal_equation
https://www.shadertoy.com/view/MtK3zD
3/ @SebAaltonen
For completeness, here’s the abs_diff functions needed for the compressor and the decompressor.
4/ @SebAaltonen
And the inverse preprocessing step you use after the zlib decompress:
5/ @SebAaltonen
The first (X=0, Y=0, Z=0) planes need different code. Here I simply don’t preprocess them. For the first scanline you need linear 1d estimate (x-2, x-1 is good). For the first plane you need 2d estimate.