Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Can "MESH_PRIMITIVE_TOO_FEW_TEXCOORDS" not be treated as an error? #68

Closed
kcoley opened this issue Feb 22, 2018 · 6 comments
Closed

Can "MESH_PRIMITIVE_TOO_FEW_TEXCOORDS" not be treated as an error? #68

kcoley opened this issue Feb 22, 2018 · 6 comments

Comments

@kcoley
Copy link

kcoley commented Feb 22, 2018

Hello!
I recently came across a model that was converted to glTF from BabylonJS. The model is able to render in BabylonJS and ThreeJS, but the glTF validator yields the MESH_PRIMITIVE_TOO_FEW_TEXCOORDS error when the model shares a material across multiple mesh primitives, but one does not actually use the textures:

i.e.

{
      "name": "material name",
      "doubleSided": true,
      "pbrMetallicRoughness": {
        "baseColorFactor": [
          0.5,
          0.5,
          0.5,
          1
        ],
        "metallicFactor": 0.1,
        "roughnessFactor": 0.4,
        "baseColorTexture": {
          "index": 0
        }
      }
    }
{
    "code": "MESH_PRIMITIVE_TOO_FEW_TEXCOORDS",
    "message": "Material is incompatible with mesh primitive: Texture binding '/materials/1/pbrMetallicRoughness/baseColorTexture' needs 'TEXCOORD_0' attribute.",
    "severity": 0,
    "pointer": "/meshes/99/primitives/0/material"
},

Is it possible to have this not treated as an error? It may cause false negatives for some models and could cause extra material duplication just to try to get rid of the errors.

Thanks!

@emackey
Copy link
Member

emackey commented Feb 22, 2018

I'm confused. How can a mesh exist, with a baseColorTexture, without using said texture? I don't think it's legal glTF to skip those coordinates, even if the WebGL frameworks tolerate it.

That said, the errors in this project are user-configurable. You can reduce the severity to Warning, Info, or Hint, or turn off the reporting of this type of error completely. See config-example.yaml. Of course, if you're trying to produce conformant glTF files, you should leave this error enabled and just supply some zeros for texture coordinates.

@lexaknyazev
Copy link
Member

supply some zeros for texture coordinates

Btw, supplying zeros doesn't require storing them in the buffer. For example, this asset defines a VEC2 floating-point accessor with no data:

{
    "asset":{
        "version":"2.0"
    },
    "accessors": [
        {
            "count": 12,
            "componentType": 5126,
            "type": "VEC2"
        }
    ]
}

@bghgary
Copy link

bghgary commented Feb 26, 2018

How can a mesh exist, with a baseColorTexture, without using said texture?

This is more of a case where a material has texture(s) but the mesh primitive pointing to the material does not have texture coordinates. I think this is a valid use of materials. The same material can be used with textures and without textures.

@lexaknyazev
Copy link
Member

Found this thread: KhronosGroup/glTF#1023 (comment).
We can demote this issue to a warning if it's a valid use case. Engines should be explicitly tested with such models to ensure that "no-texture" behavior is consistent.

@bghgary
Copy link

bghgary commented Feb 26, 2018

Ah yes, I remember that thread now. Thanks for the pointer.

https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/schema/textureInfo.schema.json#L17 currently says this:

Mesh must have corresponding texture coordinate attributes for the material to be applicable to it.

This means that a material cannot be reused the way I described.

Since it's spelled out explicitly in the spec, let's keep the validator as is. We will update the BabylonJS exporter to output two separate materials.

@kcoley
Copy link
Author

kcoley commented Feb 26, 2018

Thanks all for clarifying!

@kcoley kcoley closed this as completed Feb 26, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants