#!/usr/bin/env python3 """Report mean luminance / contrast of the level textures. FLUX happily returns a near-white blank sheet for prompts like "pale grey concrete", which renders as a blown-out void in game. Anything with a mean much above ~200 or a range under ~30 is a dud worth re-prompting. Usage: check_textures.py [name ...] """ import os import sys from PIL import Image TEX = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "assets", "textures") want = set(sys.argv[1:]) bad = 0 for f in sorted(os.listdir(TEX)): if not f.endswith(".jpg") or (want and f[:-4] not in want): continue px = list(Image.open(os.path.join(TEX, f)).convert("L").resize((48, 48)).getdata()) mean, rng = sum(px) / len(px), max(px) - min(px) flag = " <-- washed out" if mean > 205 else (" <-- featureless" if rng < 8 else "") bad += bool(flag) print("%-22s mean %3.0f range %3d%s" % (f[:-4], mean, rng, flag)) sys.exit(1 if bad else 0)