Obj2gltf Color missing

Hi, I recently tried using the obj2gltf converter and even though it ‘works’, unlike the blender exporter which exports everything perfectly, it looks like my .gltf file is missing all it’s color textures. Is there any fix for this? Thank you.

If you could share one of the OBJ+MTL files (and maybe the glTF file) people could quickly try it out and see what might be wrong there (if the files are not too large, and if they can be made public)

Otherwise: Does the blender exporter generate valid glTFs from the same OBJ inputs?
Are there any textures and images in the resulting glTF file? (Maybe it’s only a wrong file path or so…)

models.zip (225.4 KB)

Hi, thanks for your reply. Here are the models I was experimenting with. I realised that I was missing the texture files and that was likely the reason my color textures aren’t working. But I have a few questions:

  1. I realised the converted model has differences in textures such as the windows of the car as compared to the .gltf file that I got from turbosquid(Free 3D model Stylized Cartoon Car Free Free - TurboSquid 1778654). Is it a problem with the obj2gltf converter?

  2. If I want to implement this obj2gltf converter on my webpage, does that I mean I will have to request the user to input all their texture files along side their obj file?

  3. If the user have .obj, .mtl, .rgb and .flt files, will this converter still work?

The problem is rather in the MTL file. It declares the material for the window to be

newmtl WINDOW
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

The d line describes the opacity, and this is 1.0 (fully opaque) here. In order to make the windows transparent, it should be 0.5 or so.

Changing this to 0.5 and converting the model to glTF with obj2gltf should give the right result.

Specifically: When the value in the input MTL file is 1.0, then the material in the glTF file is

    {
      "name": "WINDOW",
      "pbrMetallicRoughness": {
        "baseColorFactor": [
          0.8,
          0.8,
          0.8,
          1
        ],
        "metallicFactor": 0,
        "roughnessFactor": 0.676000006
      },
      "emissiveFactor": [
        0,
        0,
        0
      ],
      "alphaMode": "OPAQUE",
      "doubleSided": false
    }

(i.e. an OPAQUE material with an alpha value of 1).

After changing the d-value in the MTL file, the material will be

    {
      "name": "WINDOW",
      "pbrMetallicRoughness": {
        "baseColorFactor": [
          0.8,
          0.8,
          0.8,
          0.5
        ],
        "metallicFactor": 0,
        "roughnessFactor": 0.676000006
      },
      "emissiveFactor": [
        0,
        0,
        0
      ],
      "alphaMode": "BLEND",
      "doubleSided": true
    }

(a BLEND material with an alpha value of 0.5)

The technical part of the answer is: Yes. (How else should the texture end up in the glTF file?).

Apart from that: How exactly you would ~“implement this converter on your webpage” may involve questions about licensing - but obj2gltf is published with the Apache License 2.0, so I think that mentioning obj2gltf (and giving proper attribution here) should be sufficient, but this is not legal advice.

RGB and FLT seem to be some specific image/texture formats. They will not automatically be supported by obj2gltf.