Textures missing when exporting from blender to gltf/glb

Hello Team!

Thank you for the wonderful engine. I am sure this is my lack of experience with 3d data formats. When I try to export a model from blender to gltf/glb, its missing its textures.
GLB in engine:

Blend2Bam also wont work with this error:
SystemError: GPU API is not available in background mode

Thanks for the assistance.

From Blender:

And fun render because its cute:

1 Like

Im guessing it has something to do with the materials. I also tried with simplepbr. No dice.

Ohhh it seems this may be related:
https://docs.blender.org/manual/en/latest/addons/import_export/scene_gltf2.html

I see this in the docs now.

Alright so it looks like the importer for Ldraw formate (i build this in a lego cad program) creates a material called “Lego Standard”, but, it is indeed a principled BSDF to a material output surface.


While I could look into importing LDraw format directly into panda. I use blender for polygon optimization (removal of unseen studs etc) and want to animate with it. So any help would be very much appreciated. Thanks.

Very interesting to note that it appears the materials in the gltf are lacking fields. I export a basic cube with principled bsdf and the tuxWing.gltf, in tux, its missing parameters.

“materials”:[
{
“doubleSided”:true,
“name”:“Material_7_c”,
“pbrMetallicRoughness”:{}
},
{
“doubleSided”:true,
“name”:“Material_179_c”,
“pbrMetallicRoughness”:{}
},

vs

“materials”:[
{
“doubleSided”:true,
“name”:“Material”,
“pbrMetallicRoughness”:{
“baseColorFactor”:[
0.8000000715255737,
0.14631381630897522,
0.1143554225564003,
1
],
“metallicFactor”:0,
“roughnessFactor”:0.5
}
}
],

Yup, so once the lego standrd material was ungrouped and directly output, it looks like the parameters are present and the material rendering.

Screenshot from 2023-07-08 23-41-49

Maybe this will help others in the future debug there issues. I suppose what I will have to do now is fix the importer for my use case and or script an ungroup loop that stored the original color. Probably both are dooable cheers!

And we have liftoff! Learned alot about the blender api as well.

If anyone needs the bare bones script:

import bpy

# Run through all materials of the current blend file
for mat in bpy.data.materials:
    if mat.node_tree:
        try:
            output = mat.node_tree.nodes["Material Output"]
            group = mat.node_tree.nodes["Group"]
            group2 = mat.node_tree.nodes["Group.001"]
            r,g,b,a = group.inputs['Color'].default_value
            bsdf = mat.node_tree.nodes.new(type="ShaderNodeBsdfPrincipled")
            bsdf.inputs["Base Color"].default_value = (r,g,b,a)
            mat.node_tree.links.new(bsdf.outputs["BSDF"], output.inputs["Surface"])
            mat.node_tree.nodes.remove(group)
            mat.node_tree.nodes.remove(group2)
        except:
            pass

2 Likes