fix(IconForge): point the texture path at the real dump directory

render.py was lifted from the scratch pipeline with its default TEXDIR still
aimed at tools/IconExtract's build output — a tool that is not in the repo.
forge.py overrides the value, so the icons built correctly and the staleness
was invisible; anyone importing render.py directly would have been sent to a
path that never existed.

Default now matches where tools/MosswartArt actually writes, and a missing
texture prints a warning instead of silently dropping out: a partial texture
set renders some parts flat grey, which reads as a lighting bug rather than a
missing extraction step.

Both icons still reproduce byte-for-byte.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-08-20 14:43:37 +02:00
parent a1ffe77af4
commit 48c44abd4a

View file

@ -1,7 +1,7 @@
"""Software rasterizer for the exported mosswart mesh.
Loads the JSON dumped by tools/MosswartArt, textures dumped by tools/IconExtract,
and renders a lit, shaded, supersampled image. Deliberately simple: z-buffer,
Loads the geometry and textures dumped by tools/MosswartArt into work/, and
renders a lit, shaded, supersampled image. Deliberately simple: z-buffer,
perspective camera, Lambert key/fill/rim + Blinn specular for wet skin.
"""
import json, glob, os, math
@ -9,8 +9,9 @@ import numpy as np
from PIL import Image
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.abspath(os.path.join(HERE, "..", ".."))
TEXDIR = os.path.join(ROOT, "tools", "IconExtract", "bin", "Release", "net10.0", "out")
# Default matches where tools/MosswartArt writes its texture dump. forge.py
# overrides this when --work points elsewhere.
TEXDIR = os.path.join(HERE, "work", "textures")
# ---------------------------------------------------------------- data loading
@ -19,6 +20,10 @@ def load_textures(ids):
for tid in ids:
hits = glob.glob(os.path.join(TEXDIR, tid + "_*.png"))
if not hits:
# Say so: a partial texture set renders some parts flat grey, which
# is easy to mistake for a lighting problem rather than a missing
# extraction step.
print(f" WARNING: no texture found for {tid} in {TEXDIR}")
continue
im = Image.open(hits[0]).convert("RGBA")
out[tid] = np.asarray(im, dtype=np.float32) / 255.0