Mesh resident block models with native culling and UV-aware merging

This commit is contained in:
Ludovic Marie
2026-10-06 22:30:16 +02:00
parent f5ba959cdc
commit a6966ab450
17 changed files with 1330 additions and 185 deletions
+26 -1
View File
@@ -65,6 +65,29 @@ def main():
if tags != worldgen.tag_resources(jars['client']):
raise ValueError('Reference block tags disagree')
lab.write_json(root / 'block-tags.json', tags)
visibility = oracle.with_name('VanillaFaceVisibilityOracle.java')
collision = oracle.with_name('VanillaCollisionOracle.java')
render_sources = base.source_hashes([visibility, collision, oracle])
render_files = ['render-definitions.json', 'occlusion.nbt']
tag_hash = lab.digest(root/'block-tags.json', 'sha256')
if not (previous.get('render_exporters_sha256') == render_sources
and previous.get('server_sha256') == origin['server_sha256']
and previous.get('block_tags_sha256') == tag_hash
and all((root/name).exists() and previous.get('render_files_sha256', {}).get(name)
== lab.digest(root/name, 'sha256') for name in render_files)):
export = lab.LOCAL/'horizon-client-render'; export.mkdir(exist_ok=True)
lab.write_json(export/'tags.json', tags)
classes = export/'classes'; classes.mkdir(exist_ok=True)
dependencies = os.pathsep.join(map(str, [jars['server'], *libraries]))
with (export/'export.log').open('w') as log:
subprocess.run(['javac', '--release', str(lock['minecraft']['java_major']), '-proc:none',
'-cp', dependencies, '-d', str(classes), str(visibility), str(collision), str(oracle)],
check=True, stdout=log, stderr=subprocess.STDOUT, timeout=3600)
subprocess.run(['java', '-Xmx768M', '-cp', str(classes)+os.pathsep+dependencies,
'dev.horizonlab.parity.VanillaFaceVisibilityOracle', 'export', str(export)],
check=True, stdout=log, stderr=subprocess.STDOUT, timeout=3600)
(root/'render-definitions.json').write_bytes((export/'definitions.json').read_bytes())
(root/'occlusion.nbt').write_bytes((export/'occlusion.nbt').read_bytes())
count = 0
prefixes = ('assets/minecraft/blockstates/', 'assets/minecraft/models/block/',
'assets/minecraft/textures/block/')
@@ -82,7 +105,9 @@ def main():
target.parent.mkdir(parents=True, exist_ok=True)
target.write_bytes(data)
count += 1
lab.write_json(manifest, {'schema': 2, **origin,
lab.write_json(manifest, {'schema': 3, **origin,
'render_exporters_sha256': render_sources,
'render_files_sha256': {name: lab.digest(root/name, 'sha256') for name in render_files},
'model_state_exporters_sha256': binding_sources,
'model_states_sha256': lab.digest(model_states, 'sha256'), 'data_version': version['world_version'],
'facts_sha256': lab.digest(facts, 'sha256'),
+13 -8
View File
@@ -21,7 +21,7 @@ except ImportError:
def resource_fingerprint(root):
files = [root / 'facts.json', root / 'model-states.json', root / 'block-tags.json', root / 'horizon-resources.json',
files = [root / 'facts.json', root / 'model-states.json', root / 'render-definitions.json', root / 'occlusion.nbt', root / 'block-tags.json', root / 'horizon-resources.json',
*sorted(path for path in (root / 'assets').rglob('*') if path.is_file())]
digest = hashlib.sha256()
for path in files:
@@ -50,7 +50,8 @@ def main():
*sorted((lab.ROOT / 'crates/horizon-assets/src').rglob('*.rs'))]
oracle = lab.ROOT / 'mods/horizon/src/test/java/dev/horizonlab/parity/VanillaGallerySelectionOracle.java'
helper = oracle.with_name('VanillaCuboidModelOracle.java')
sources += [oracle, helper, lab.ROOT/'tools/test_model_baking_parity.py', lab.ROOT/'tools/test_rust_parity.py', lab.ROOT/'tools/lab.py', lab.ROOT/'tools/prepare_native_client.py']
heightmap = oracle.with_name('VanillaHeightmapOracle.java')
sources += [oracle, helper, heightmap, lab.ROOT/'tools/test_model_baking_parity.py', lab.ROOT/'tools/test_rust_parity.py', lab.ROOT/'tools/lab.py', lab.ROOT/'tools/prepare_native_client.py']
for crate in ['horizon-core', 'horizon-world']:
sources += [lab.ROOT/'crates'/crate/'Cargo.toml', *sorted((lab.ROOT/'crates'/crate/'src').rglob('*.rs'))]
tested_sources = {
@@ -74,8 +75,10 @@ def main():
stdout=log, stderr=subprocess.STDOUT, timeout=120)
result = json.loads(report.read_text())
if (result.get('error') is not None or result.get('presented_frames') != 30
or result.get('resident_chunks') != 9 or result.get('merged_quads', 0) <= 0
or result.get('model_quads') != 209 or len(result.get('model_gallery', [])) != 16
or result.get('resident_chunks') != 9 or result.get('merged_quads') != 3169
or result.get('visible_model_faces') != 5991 or result.get('culled_model_faces') != 59636
or result.get('model_blocks') != 10919
or result.get('model_quads') != 179 or len(result.get('model_gallery', [])) != 16
or result.get('sprite_layers') != 18 or result.get('animated_sprites') != 1
or not result.get('adapter') or min(result.get('window_size', [0])) <= 0):
raise RuntimeError('Incomplete native client presentation: ' + str(report))
@@ -85,19 +88,21 @@ def main():
native = root/'gallery-selection.json'
with (root/'gallery-selection.log').open('w') as log:
subprocess.run(['javac', '--release', str(lock['minecraft']['java_major']), '-proc:none', '-cp', dependencies,
'-d', str(classes), str(oracle), str(helper)], cwd=lab.ROOT, check=True,
'-d', str(classes), str(oracle), str(helper), str(heightmap)], cwd=lab.ROOT, check=True,
stdout=log, stderr=subprocess.STDOUT, timeout=3600)
subprocess.run(['java', '-Xmx512M', '-cp', str(classes)+os.pathsep+dependencies,
'dev.horizonlab.parity.VanillaGallerySelectionOracle', str(report), str(native)],
'dev.horizonlab.parity.VanillaGallerySelectionOracle', str(report), str(native), str(root/'26.3')],
cwd=lab.ROOT, check=True, stdout=log, stderr=subprocess.STDOUT, timeout=3600)
selections = json.loads(native.read_text())
native_result = json.loads(native.read_text())
selections = native_result['gallery']
result['native_scene_culling'] = native_result['scene']
if len(selections) != len(result['model_gallery']):
raise RuntimeError('Incomplete native gallery selection check')
result['native_selection'] = {'matched_placements': len(selections),
'selected_parts': sum(len(s['models']) for s in selections),
'client_jar_sha256': lab.digest(jars['client'], 'sha256'),
'output_sha256': lab.digest(native, 'sha256'),
'scope': 'Actual native registry states, blockstate dispatch, root baking with tagged empty geometry, and legacy collection using state.getSeed(position). Model names and transform matrices match scene selections; no shader/pixel parity claim.'}
'scope': 'Actual native registry states, blockstate dispatch, tagged root baking and legacy collection using state.getSeed(position). All 16 featured placements match model names/transforms. An independently constructed native scene also matches total occupied blocks and visible/culled model faces using native parent resolution, rotated culling directions and Block.shouldRenderFace. No shader/pixel parity claim.'}
if resource_fingerprint(root / '26.3') != resources:
raise RuntimeError('Resources changed during native client verification')
result['resource_files'] = resources