95db0fce9d
Horizon averaged each mip level's alpha plainly, so a cutout texture's transparent edges grew past the alpha test with every level: the cactus side's transparent border columns opened see-through slits along its corners from about 40 blocks, more than vanilla shows. The sprite array's mips now come from a port of MipmapGenerator.generateMipLevels: the texture's .mcmeta mipmap_strategy (auto: cutout when a pixel is fully transparent) and alpha_cutoff_bias, solidify or the dark fill on the base, meanLinear or darkenedAlphaBlend, and scaleAlphaToCoverage keeping every cutout level's alpha-test coverage at the base level's. tools/test_mipmap_parity.py runs vanilla's MipmapGenerator and the port on every static 16x16 block texture and a sample of item textures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
"""Sprite mip levels against the pinned client's MipmapGenerator.
|
|
|
|
Every static square block texture and a sample of item textures, with their
|
|
.mcmeta `texture` settings (mipmap_strategy, alpha_cutoff_bias):
|
|
VanillaMipmapOracle runs MipmapGenerator.generateMipLevels (solidify or the
|
|
dark fill, meanLinear or darkenedAlphaBlend, scaleAlphaToCoverage for cutout
|
|
sprites) and the `mipmap_probe` example loads the same sprites through
|
|
`sprites::Sprites` and runs `mipmap::generate`; every level's pixels must be
|
|
identical."""
|
|
import json
|
|
import struct
|
|
|
|
try:
|
|
from . import oracle_harness as oh
|
|
except ImportError:
|
|
import oracle_harness as oh
|
|
|
|
NAME = 'mipmap-parity'
|
|
|
|
|
|
def size(png):
|
|
with open(png, 'rb') as f:
|
|
head = f.read(24)
|
|
return struct.unpack('>II', head[16:24])
|
|
|
|
|
|
def make_input(build):
|
|
root = oh.lab.LOCAL / 'horizon-client' / '26.3'
|
|
textures = root / 'assets/minecraft/textures'
|
|
names = []
|
|
for folder, every in (('block', 1), ('item', 7)):
|
|
for i, png in enumerate(sorted((textures / folder).glob('*.png'))):
|
|
if i % every:
|
|
continue
|
|
meta = png.with_name(png.name + '.mcmeta')
|
|
if meta.is_file() and 'animation' in json.loads(meta.read_text(encoding='utf-8')):
|
|
continue
|
|
w, h = size(png)
|
|
if w != h or w & (w - 1) or w != 16:
|
|
continue
|
|
names.append(f'minecraft:{folder}/{png.stem}')
|
|
path = build / 'sprites.txt'
|
|
path.write_text('\n'.join([str(root)] + names) + '\n', encoding='utf-8')
|
|
return path, len(names)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
oh.differential(NAME, 'VanillaMipmapOracle', 'mipmap_probe', make_input,
|
|
'MipmapGenerator.generateMipLevels (solidify, fillEmptyAreasWithDarkColor, meanLinear, '
|
|
'darkenedAlphaBlend, alphaTestCoverage, scaleAlphaToCoverage) on static 16x16 block and item sprites '
|
|
'with their .mcmeta texture settings',
|
|
sources=[oh.lab.ROOT / 'crates/horizon-client/src/mipmap.rs',
|
|
oh.lab.ROOT / 'crates/horizon-client/src/sprites.rs'])
|