Nodes/ComfyUI_Antonioilev_Lightpack/πŸ“¦ GLB Texture Extractor
ComfyUI Node

πŸ“¦ GLB Texture Extractor

Pulls the basecolor out of a .glb, and only the basecolor

By AntonioilevΒ·Created 2 days agoΒ·Updated a day agoΒ· 0
πŸ“¦ GLB Texture Extractor
    • texture
    • alpha_mask
    • trimesh_mesh
    • saved_path
    β—„glb_pathpath/to/your/model.glbβ–Ί
    β—„save_dir/mnt/l/Game_2/Art/Chars/Char1/Texturingβ–Ί
    β—„filenameextracted_basecolorβ–Ί
    β—„save_texturetrueβ–Ί

    Here's a workflow that used to mean opening Blender: you generate a textured asset, and now you want that texture as an image so you can push it through img2img, upscale it, inpaint a logo off the chest, or feed it to a normal map converter. Your .glb is one binary blob and the texture is inside it. This node pops it out and hands it to you as a ComfyUI IMAGE.

    What you get

    Four outputs, in this order:

    • texture (IMAGE) - the base colour texture, converted to RGB, as a [1, H, W, 3] tensor ready for any image node.
    • alpha_mask (MASK) - if the source texture was RGBA, the alpha channel as a mask. If it wasn't, you get a mask of all ones (fully white), not an empty one. That distinction matters: a workflow that treats "white mask" as "everything visible" is fine, one that treats it as "opaque region" will do nothing.
    • trimesh_mesh (TRIMESH) - the mesh itself, so you can branch: texture out one side to an upscaler, mesh out the other to Refine Mesh.
    • saved_path (STRING) - the path of the PNG it wrote, or an empty string.

    Mechanism is short and slightly naive, in a way worth knowing. It calls trimesh.load(glb_path, force='mesh') and then looks for material.image or material.baseColorTexture, falling back to a 1024Γ—1024 white image if it finds nothing (and printing a warning you'll only see in the console). So: one texture, and it's the base colour. No metallic/roughness, no normal, no emissive, no AO. On a PBR asset from Hunyuan3D 2.1 - which is prized precisely for shipping metalness/roughness/albedo as separate channels - you get the albedo and the rest stays in the file. And force='mesh' collapses a multi-part scene into a single mesh, so on an asset with several materials you get whichever one trimesh surfaces first, with no warning that others existed.

    If what you need is "the texture, all of it", this is a starter, not the whole story.

    The inputs

    • glb_path - a full path to the .glb. Not a dropdown, not relative to input/; type or paste it. Missing file raises a clear FileNotFoundError, which is one of the few loud failures in this pack.
    • save_dir - change this immediately. The default is /mnt/l/Game_2/Art/Chars/Char1/Texturing, the author's own drive. On Windows or macOS you'll get an error print and an empty saved_path.
    • filename - the base name; any extension you type is stripped and .png is appended. Always PNG, no format choice.
    • save_texture (default on) - uncheck it to get the texture output without touching disk, which is what you want when you're just routing into an upscaler.

    Install

    cd ComfyUI/custom_nodes
    git clone https://github.com/Antonioilev/ComfyUI_Antonioilev_Lightpack.git
    python -m pip install trimesh pillow
    

    Restart. Manager handles the clone (search Antonioilev Light Pack) but not the dependencies - the repo ships no requirements.txt and no install script, so trimesh in particular is on you. Run pip against ComfyUI's own interpreter, not your system one; the ten-minutes-of-confusion failure mode in this ecosystem is installing trimesh into a different Python and watching the node still not appear. The startup line [Antonioilev_Light_pack] Loaded N nodes (M failed) plus the !!! error underneath tells you if a module failed to import.

    Troubleshooting

    White texture. The GLB's material isn't in the shape trimesh recognises (this hapens with some exporters and with files whose textures are referenced externally rather than embedded). Check the console for the "No texture found, generating dummy white texture" line - if it's there, the extraction genuinely failed and you should unzip the GLB yourself (a .glb is a container; the images are in there) or re-export from Blender.

    The wrong texture. Multi-material asset, first-match wins. Split the asset by part upstream and extract per part.

    It saved nothing. save_dir doesn't exist or isn't writable on this machine. The save is wrapped in a try/except that prints and continues, so nothing screams - saved_path coming back empty is your signal.

    Texture looks washed out or has a matte grey box in it. That's the alpha being flattened: the image is converted to plain RGB and transparent regions were black, not white. Use the alpha_mask output to composite it over something sane before you upscale or img2img it, or you'll be inpainting a halo that was never in the asset.

    CategoryAntonioilev/Texturing

    Inputs (4)

    NameTypeDefaultDescription
    glb_pathSTRINGpath/to/your/model.glbβ€”
    save_dirSTRING/mnt/l/Game_2/Art/Chars/Char1/Texturingβ€”
    filenameSTRINGextracted_basecolorβ€”
    save_textureBOOLEANtrueβ€”

    Outputs (4)

    NameTypeDescription
    textureIMAGEβ€”
    alpha_maskMASKβ€”
    trimesh_meshTRIMESHβ€”
    saved_pathSTRINGβ€”