Fix Editor-Live-Texturen: Pack-Original-Zuordnung nach Materialname (t_50a07d4b, aa94bde korrigiert)
aa94bde hat im Live-Pfad die alten Camo-Dateien (desert_multicam_*) verwendet und
zusaetzlich per Inhaltsvergleich auch KORREKTE Texturen wieder durch Camo ersetzt
- das haette die Palette-Arbeit aus t_279df760 im Editor rueckgaengig gemacht.
Jetzt: Zuordnung Materialname -> Pack-Textur (military_base -> Demonstration_Textures1.png,
picture_1/2/3 -> Demonstration_picture_N.png), Pfad ../../../textures/military_desert/
(Client-Repo, dort liegen die Dateien seit 88fded1). Fuer den Inhalt gibt es EINE Quelle:
tools/PACK_TEXTURE_MAPPING.md. Fuer den Inhalt gibt es EINE Quelle: dieselbe Tabelle.
Flaechen mit bereits aufgeloester Textur bleiben unangetastet.
This commit is contained in:
parent
aa94bde708
commit
d0d4fbd221
3 changed files with 87 additions and 56 deletions
|
|
@ -29,17 +29,21 @@ const MANIFEST_PATH := "res://library/objects.json"
|
||||||
static var _manifest: Dictionary = {}
|
static var _manifest: Dictionary = {}
|
||||||
static var _manifest_geladen := false
|
static var _manifest_geladen := false
|
||||||
|
|
||||||
# Camo-Fix (t_50a07d4b): GLTFDocument löst externe Textur-URIs (Sibling-Repos,
|
# WYSIWYG-Fix (t_c8748efc, korrigiert in t_279df760): GLTFDocument löst externe
|
||||||
# außerhalb res://) NICHT auf — im Editor-Viewport blieben die GLB-Objekte
|
# Textur-URIs (Sibling-Repos, außerhalb res://) NICHT auf — im Editor-Viewport
|
||||||
# untexturiert/Editor-Farbe, während sie im Spiel getextured sind
|
# blieben die GLB-Objekte untexturiert/Editor-Farbe, während sie im Spiel
|
||||||
# (WYSIWYG-Bruch, belegt in t_c8748efc). camo_tex_setzen lädt die Multicam-
|
# getextured sind. Flächen OHNE albedo_texture bekommen hier die Textur, die das
|
||||||
# Textur DIREKT von der Platte (Image.load_from_file, ohne Import-System) und
|
# ITHappy-Pack für ihren MATERIALNAMEN vorsieht — Zuordnung identisch zu
|
||||||
# setzt sie auf alle Flächen ohne albedo_texture — derselbe Mechanismus wie
|
# tools/PACK_TEXTURE_MAPPING.md (Client-Repo, verbindlich):
|
||||||
# im Thumbnail-Pfad (gen_thumbs.gd). Zuordnung je Kategorie exakt wie in
|
# military_base (+_00x) = Palette (Demonstration_Textures1.png, 1024²)
|
||||||
# tools/CAMO_TEXTURE_MAPPING.md (Client-Repo, verbindlich):
|
# picture_1/2/3 = echtes Multicam (Demonstration_picture_N.png, 2048²)
|
||||||
# _1 = Objekte, _2 = Boden (nature: ground*/decal*), _3 = ungenutzt.
|
# Wichtig: Nichts wird überschrieben — GLTF-aufgelöste Texturen bleiben unangetastet.
|
||||||
## Textur-Praefixe der nature-Unterkategorie, die Bodentextur _2 bekommen.
|
# (Der frühere Inhalt-Vergleich + Kategorie-Camo stammte aus aa94bde und hat auch
|
||||||
const CAMO_TEX_BODEN_PRAEFIXE := ["ground", "decal"]
|
# korrekte Pack-Texturen wieder durch Camo ersetzt — das war der Fehler.)
|
||||||
|
const PACK_TEX_PALETTE := "Demonstration_Textures1.png"
|
||||||
|
const PACK_TEX_PICTURE_1 := "Demonstration_picture_1.png"
|
||||||
|
const PACK_TEX_PICTURE_2 := "Demonstration_picture_2.png"
|
||||||
|
const PACK_TEX_PICTURE_3 := "Demonstration_picture_3.png"
|
||||||
|
|
||||||
# ImageTexture pro Textur-Pfad gecacht — sonst erzeugt jede der 291 GLBs
|
# ImageTexture pro Textur-Pfad gecacht — sonst erzeugt jede der 291 GLBs
|
||||||
# ihre eigene 2048²-Textur (~16 MB VRAM je Stück statt 2 × 16 MB gesamt).
|
# ihre eigene 2048²-Textur (~16 MB VRAM je Stück statt 2 × 16 MB gesamt).
|
||||||
|
|
@ -248,59 +252,38 @@ static func _normalisiert(mesh: ArrayMesh) -> ArrayMesh:
|
||||||
## aus dem Cache — gleiche Optik (WYSIWYG bleibt), eine Quelle statt Kopien.
|
## aus dem Cache — gleiche Optik (WYSIWYG bleibt), eine Quelle statt Kopien.
|
||||||
## Eingebettete/Fremd-Texturen (Alt-Bestand, Waffen-GLBs) bleiben unangetastet.
|
## Eingebettete/Fremd-Texturen (Alt-Bestand, Waffen-GLBs) bleiben unangetastet.
|
||||||
static func camo_tex_setzen(mesh: Mesh, glb_pfad: String) -> void:
|
static func camo_tex_setzen(mesh: Mesh, glb_pfad: String) -> void:
|
||||||
# Kategorie + OID aus dem Pfad: .../military_desert/<kategorie>/<oid>.glb
|
# Siehe Kopf-Kommentar: nur Flächen OHNE aufgelöste Textur werden versorgt.
|
||||||
var teile := glb_pfad.split("/")
|
var tex_dir := glb_pfad.get_base_dir().path_join("../../../textures/military_desert")
|
||||||
var kategorie := ""
|
|
||||||
var oid := ""
|
|
||||||
for i in teile.size():
|
|
||||||
if teile[i] == "military_desert" and i + 2 < teile.size():
|
|
||||||
kategorie = teile[i + 1]
|
|
||||||
oid = teile[i + 2].get_basename()
|
|
||||||
break
|
|
||||||
if kategorie.is_empty():
|
|
||||||
return
|
|
||||||
var nr := 1
|
|
||||||
if kategorie == "nature":
|
|
||||||
for p in CAMO_TEX_BODEN_PRAEFIXE:
|
|
||||||
if oid.begins_with(p):
|
|
||||||
nr = 2
|
|
||||||
break
|
|
||||||
var tex_dir := glb_pfad.get_base_dir().path_join("../textures")
|
|
||||||
# Kategorie-Textur (Fächer OHNE albedo_texture) + Vergleichs-Set: BEIDE
|
|
||||||
# Multicam-Dateien — gebackene GLBs können Misch-Referenzen haben (z. B.
|
|
||||||
# barrel_001: _2 + _1). Die Dedup-Zuordnung geschieht pro Fläche über den
|
|
||||||
# INHALT, nicht per Kategorie-Blindregel.
|
|
||||||
var kategorie_tex_pfad := tex_dir.path_join("desert_multicam_%d.png" % nr)
|
|
||||||
var kandidaten: Array = [kategorie_tex_pfad]
|
|
||||||
var andere_nr := 2 if nr == 1 else 1
|
|
||||||
var andere_pfad := tex_dir.path_join("desert_multicam_%d.png" % andere_nr)
|
|
||||||
if FileAccess.file_exists(andere_pfad):
|
|
||||||
kandidaten.append(andere_pfad)
|
|
||||||
var kategorie_tex := _camo_tex(kategorie_tex_pfad) # null + push_warning, wenn fehlt
|
|
||||||
for s in mesh.get_surface_count():
|
for s in mesh.get_surface_count():
|
||||||
var mat := mesh.surface_get_material(s)
|
var mat := mesh.surface_get_material(s)
|
||||||
if not (mat is BaseMaterial3D):
|
if not (mat is BaseMaterial3D):
|
||||||
continue
|
continue
|
||||||
var bm := mat as BaseMaterial3D
|
var bm := mat as BaseMaterial3D
|
||||||
var alt := bm.albedo_texture
|
if bm.albedo_texture != null:
|
||||||
if alt == null:
|
|
||||||
# Fläche ohne Textur (GLTF-Fallback) → Kategorie-Textur
|
|
||||||
# (gen_thumbs-Mechanismus, t_c8748efc). Fehlt die Datei: warnt
|
|
||||||
# _camo_tex (push_warning) statt still weiß zu rendern.
|
|
||||||
if kategorie_tex != null:
|
|
||||||
bm.albedo_texture = kategorie_tex
|
|
||||||
else:
|
|
||||||
push_warning("GlbMeshStore: %s (%s) bleibt untexturiert — Camo-Textur fehlt: %s"
|
|
||||||
% [oid, kategorie, kategorie_tex_pfad])
|
|
||||||
continue
|
continue
|
||||||
var ersetzung := _camo_ersetzung_fuer(alt, kandidaten)
|
var datei := pack_datei_fuer(bm.resource_name)
|
||||||
if ersetzung != null:
|
var tex := _camo_tex(tex_dir.path_join(datei))
|
||||||
bm.albedo_texture = ersetzung
|
if tex != null:
|
||||||
|
bm.albedo_texture = tex
|
||||||
|
else:
|
||||||
|
push_warning("GlbMeshStore: Pack-Textur fehlt fuer Material '%s': %s" % [bm.resource_name, datei])
|
||||||
|
|
||||||
|
|
||||||
## Dekodierte Multicam-Bilddatei (RAM-gecacht, einmal je Pfad dekodiert).
|
## Materialname (GLTF) -> Pack-Texturdatei. Quelle: tools/PACK_TEXTURE_MAPPING.md (Client).
|
||||||
## warnen=true: fehlende/nicht ladbare Datei → push_warning (Karten-Pflicht:
|
static func pack_datei_fuer(material_name: String) -> String:
|
||||||
## klar warnen statt still grau/weiß zu rendern). null = nicht ladbar.
|
match material_name:
|
||||||
|
"picture_1":
|
||||||
|
return PACK_TEX_PICTURE_1
|
||||||
|
"picture_2":
|
||||||
|
return PACK_TEX_PICTURE_2
|
||||||
|
"picture_3":
|
||||||
|
return PACK_TEX_PICTURE_3
|
||||||
|
"military_base":
|
||||||
|
return PACK_TEX_PALETTE
|
||||||
|
if material_name.begins_with("military_base"):
|
||||||
|
return PACK_TEX_PALETTE
|
||||||
|
return PACK_TEX_PALETTE
|
||||||
|
|
||||||
static func _camo_image(pfad: String, warnen: bool) -> Image:
|
static func _camo_image(pfad: String, warnen: bool) -> Image:
|
||||||
if _camo_bild_cache.has(pfad):
|
if _camo_bild_cache.has(pfad):
|
||||||
var v: Variant = _camo_bild_cache[pfad]
|
var v: Variant = _camo_bild_cache[pfad]
|
||||||
|
|
|
||||||
47
tests/probe_pack_tex_live.gd
Normal file
47
tests/probe_pack_tex_live.gd
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
extends SceneTree
|
||||||
|
## Operator-Nachweis (t_50a07d4b-Korrektur): Welche Textur bekommt der Live-Pfad?
|
||||||
|
## Erwartung: Palette 1024² fuer military_base, 2048² fuer picture_*.
|
||||||
|
## Lauf: /opt/data/home/bin/godot4 --headless --path . -s res://tests/probe_pack_tex_live.gd
|
||||||
|
|
||||||
|
const GlbMeshStore := preload("res://src/viewport/glb_mesh_store.gd")
|
||||||
|
|
||||||
|
|
||||||
|
func _initialize() -> void:
|
||||||
|
var faelle := [
|
||||||
|
["barrier_001", "military_base -> Palette 1024"],
|
||||||
|
["wall_001", "military_base -> Palette 1024"],
|
||||||
|
["apc_002", "picture_* -> Multicam 2048"],
|
||||||
|
["tent_001", "gemischt"],
|
||||||
|
]
|
||||||
|
var fehler: Array = []
|
||||||
|
for f in faelle:
|
||||||
|
var oid: String = f[0]
|
||||||
|
var mesh: Mesh = GlbMeshStore.mesh_fuer(oid)
|
||||||
|
if mesh == null:
|
||||||
|
print(" %-12s KEIN MESH (uebersprungen)" % oid)
|
||||||
|
continue
|
||||||
|
print(" %s (%s) Flaechen: %d" % [oid, f[1], mesh.get_surface_count()])
|
||||||
|
for s in mesh.get_surface_count():
|
||||||
|
var mat := mesh.surface_get_material(s)
|
||||||
|
var name := "-"
|
||||||
|
var groesse := "keine Textur"
|
||||||
|
if mat is BaseMaterial3D:
|
||||||
|
name = String((mat as BaseMaterial3D).resource_name)
|
||||||
|
var t := (mat as BaseMaterial3D).albedo_texture
|
||||||
|
if t != null:
|
||||||
|
groesse = "%dx%d" % [t.get_width(), t.get_height()]
|
||||||
|
print(" Flaeche %d: Material='%s' Textur=%s" % [s, name, groesse])
|
||||||
|
if groesse == "keine Textur":
|
||||||
|
fehler.append("%s Flaeche %d ohne Textur" % [oid, s])
|
||||||
|
elif name.begins_with("picture") and not groesse.begins_with("2048"):
|
||||||
|
fehler.append("%s: picture-Material hat %s statt 2048er" % [oid, groesse])
|
||||||
|
elif name.begins_with("military_base") and not groesse.begins_with("1024"):
|
||||||
|
fehler.append("%s: military_base hat %s statt 1024er" % [oid, groesse])
|
||||||
|
print("")
|
||||||
|
if fehler.is_empty():
|
||||||
|
print("PROBE_PACK_TEX_LIVE_OK")
|
||||||
|
else:
|
||||||
|
for x in fehler:
|
||||||
|
print(" FEHLER: %s" % x)
|
||||||
|
print("PROBE_PACK_TEX_LIVE_FAIL")
|
||||||
|
quit()
|
||||||
1
tests/probe_pack_tex_live.gd.uid
Normal file
1
tests/probe_pack_tex_live.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bkc3lgmgvaxd3
|
||||||
Loading…
Reference in a new issue