fixed color addition

This commit is contained in:
Yousef Rafat 2026-03-25 23:51:54 +02:00
parent d2c37c222a
commit 22dcd81fb3
3 changed files with 5 additions and 2 deletions

View File

@ -782,7 +782,7 @@ class Trellis2(nn.Module):
mode = "structure_generation" mode = "structure_generation"
not_struct_mode = False not_struct_mode = False
if is_1024 and mode == "shape_generation" and not is_512_run: if is_1024 and not_struct_mode and not is_512_run:
context = embeds context = embeds
sigmas = transformer_options.get("sigmas")[0].item() sigmas = transformer_options.get("sigmas")[0].item()
@ -825,7 +825,6 @@ class Trellis2(nn.Module):
x_st = SparseTensor(feats=feats_flat, coords=batched_coords.to(torch.int32)) x_st = SparseTensor(feats=feats_flat, coords=batched_coords.to(torch.int32))
if mode == "shape_generation": if mode == "shape_generation":
# TODO
if is_512_run: if is_512_run:
out = self.img2shape_512(x_st, t_eval, c_eval) out = self.img2shape_512(x_st, t_eval, c_eval)
else: else:

View File

@ -591,6 +591,9 @@ def save_glb(vertices, faces, filepath, metadata=None, colors=None):
gltf["bufferViews"].append({"buffer": 0, "byteOffset": colors_byte_offset, "byteLength": colors_byte_length, "target": 34962}) gltf["bufferViews"].append({"buffer": 0, "byteOffset": colors_byte_offset, "byteLength": colors_byte_length, "target": 34962})
gltf["accessors"].append({"bufferView": 2, "byteOffset": 0, "componentType": 5126, "count": len(colors_np), "type": "VEC3"}) gltf["accessors"].append({"bufferView": 2, "byteOffset": 0, "componentType": 5126, "count": len(colors_np), "type": "VEC3"})
gltf["meshes"][0]["primitives"][0]["attributes"]["COLOR_0"] = 2 gltf["meshes"][0]["primitives"][0]["attributes"]["COLOR_0"] = 2
# Define a base material so Three.js actually activates vertex coloring
gltf["materials"] =[{"pbrMetallicRoughness": {"baseColorFactor": [1.0, 1.0, 1.0, 1.0]}}]
gltf["meshes"][0]["primitives"][0]["material"] = 0
if metadata is not None: if metadata is not None:
gltf["asset"]["extras"] = metadata gltf["asset"]["extras"] = metadata

View File

@ -53,6 +53,7 @@ def paint_mesh_with_voxels(mesh, voxel_coords, voxel_colors, resolution):
device = comfy.model_management.vae_offload_device() device = comfy.model_management.vae_offload_device()
origin = torch.tensor([-0.5, -0.5, -0.5], device=device) origin = torch.tensor([-0.5, -0.5, -0.5], device=device)
# TODO: generic independent node? if so: figure how pass the resolution parameter
voxel_size = 1.0 / resolution voxel_size = 1.0 / resolution
# map voxels # map voxels