From adf1b1736f4daaf368f93843273b42bfe4bf8f8f Mon Sep 17 00:00:00 2001 From: maj00r Date: Wed, 14 Oct 2026 23:42:43 +0200 Subject: [PATCH] fix(tools): metalness is checked on a nearest sample of the B channel instead of a box-averaged one, so thin metal strips with B only 0 or 255 are no longer reported as half metal because downscaling averages their edges with the paint around them --- tools/materials/validate_materials.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/materials/validate_materials.py b/tools/materials/validate_materials.py index 13209676..7d3f90f5 100644 --- a/tools/materials/validate_materials.py +++ b/tools/materials/validate_materials.py @@ -183,6 +183,7 @@ class Images: if image.mode != 'RGBA': image = image.convert('RGBA') channels = [np.asarray(c.resize((SIZE, SIZE), Image.BOX), dtype=np.float32) / 255 for c in image.split()] + channels.append(np.asarray(image.split()[2].resize((SIZE, SIZE), Image.NEAREST), dtype=np.float32) / 255) result = np.dstack(channels) except Exception as e: result = str(e) @@ -323,8 +324,9 @@ def check(mat, values, nested, shaders, resolver, images, rel): reflect = max(reflect, 0.5) if reflect < METAL_REFLECTIVITY_MIN: add(WARN, 'metal z odbiciem %.2f (alfa normalmapy * param_reflection, norma >= %.1f): bez otoczenia jest ciemny' % (reflect, METAL_REFLECTIVITY_MIN)) - middle = ((B > 0.15) & (B < 0.85) & mask) - anymetal = ((B > 0.15) & mask) + Bn = sg[..., 4] + middle = ((Bn > 0.15) & (Bn < 0.85) & mask) + anymetal = ((Bn > 0.15) & mask) if anymetal.sum() > 0.01 * mask.sum() and middle.sum() > 0.3 * anymetal.sum(): add(WARN, 'B (metalicznosc) nie jest 0/1 na %d%% metalu' % (100 * middle.sum() / anymetal.sum())) bb = blur(B, 3)