arabago96 commited on
Commit
c9d8610
·
verified ·
1 Parent(s): 92a32a4

Update trellis/utils/postprocessing_utils.py

Browse files
Files changed (1) hide show
  1. trellis/utils/postprocessing_utils.py +10 -10
trellis/utils/postprocessing_utils.py CHANGED
@@ -453,24 +453,24 @@ def to_glb(
453
  )
454
  texture = Image.fromarray(texture)
455
 
456
- # rotate mesh (from z-up to y-up)
457
  vertices = vertices @ np.array([[1, 0, 0], [0, 0, -1], [0, 1, 0]])
458
 
459
- # OLD CODE (causes pale AR appearance):
460
- # material = trimesh.visual.material.PBRMaterial(
461
- # roughnessFactor=1.0,
462
- # baseColorTexture=texture,
463
- # baseColorFactor=np.array([255, 255, 255, 255], dtype=np.uint8)
464
- # )
465
-
466
- # NEW CODE (fixed - triggers Model Viewer to add IOR):
467
  material = trimesh.visual.material.PBRMaterial(
468
  baseColorTexture=texture
469
  )
470
 
471
  mesh = trimesh.Trimesh(vertices, faces, visual=trimesh.visual.TextureVisuals(uv=uvs, material=material))
472
- return mesh
473
 
 
 
 
 
 
 
 
 
474
 
475
 
476
  def simplify_gs(
 
453
  )
454
  texture = Image.fromarray(texture)
455
 
456
+ # rotate mesh (from z-up to y-up)
457
  vertices = vertices @ np.array([[1, 0, 0], [0, 0, -1], [0, 1, 0]])
458
 
459
+ # Create material WITHOUT explicit factors (lets Model Viewer add IOR/clearcoat in USDZ)
 
 
 
 
 
 
 
460
  material = trimesh.visual.material.PBRMaterial(
461
  baseColorTexture=texture
462
  )
463
 
464
  mesh = trimesh.Trimesh(vertices, faces, visual=trimesh.visual.TextureVisuals(uv=uvs, material=material))
 
465
 
466
+ # CRITICAL: Compute vertex normals - triggers Model Viewer to add ior/clearcoat to USDZ
467
+ # This fixes pale appearance in iOS AR!
468
+ mesh.vertex_normals # Access triggers auto-computation if missing
469
+
470
+ if verbose:
471
+ print(f"✅ Generated {len(mesh.vertex_normals)} vertex normals for iOS AR compatibility")
472
+
473
+ return mesh
474
 
475
 
476
  def simplify_gs(