From 77a46d0240792330d222affa25c4fc1925a08233 Mon Sep 17 00:00:00 2001 From: Bruno Fargnoli Date: Tue, 17 Mar 2026 21:09:54 +0100 Subject: [PATCH] Fixed texture projection --- texture_projection_multiview.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/texture_projection_multiview.py b/texture_projection_multiview.py index d86c123..f6e30a0 100644 --- a/texture_projection_multiview.py +++ b/texture_projection_multiview.py @@ -471,10 +471,22 @@ def texture_mesh_with_multiview( else: # No existing texture found – fall back to projection-only output - print(" WARNING: No existing PBR baseColorTexture found on mesh, " - "outputting projection-only texture (holes will be transparent).") + print( + " WARNING: No existing PBR baseColorTexture found on mesh, " + "outputting projection-only texture (holes will be transparent)." + ) + + # RGB from projection color_np = (projected_color.cpu().numpy() * 255).clip(0, 255).astype(np.uint8) - alpha_np = composite_mask.cpu().numpy().astype(np.uint8) * 255 + + # Alpha from projection confidence + conf_np = confidence.cpu().numpy() + + # Slight threshold to remove noise + alpha_mask = conf_np > 0.01 + + alpha_np = (conf_np * 255).clip(0, 255).astype(np.uint8) + alpha_np[~alpha_mask] = 0 if fill_holes: print('Filling holes and padding UV seams ...')