Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Cannot read extensions of texture info objects #179

Closed
ghost opened this issue Jul 23, 2019 · 5 comments
Closed

Cannot read extensions of texture info objects #179

ghost opened this issue Jul 23, 2019 · 5 comments
Labels
bug extension glTF extension

Comments

@ghost
Copy link

ghost commented Jul 23, 2019

I might miss something here, but given the setup of a Material as a collection of Parameters rather than Values, I can't access extensions defined inside those objects because Parameter doesn't have extensions. Specifically, the KHR_texture_transform extension is impossible to process like this.

@syoyo
Copy link
Owner

syoyo commented Jul 23, 2019

but given the setup of a Material as a collection of Parameters rather than Values, I can't access extensions defined inside those objects because Parameter doesn't have extensions

Confirmed > https://github.com/syoyo/tinygltf/blob/master/tiny_gltf.h#L3518

At least we need to add a feature to parse textureInfo to consider extensions property of texture parameter in material.

https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#reference-textureinfo

(as far as I know, I guess textureInfo was not present when I started to implement tinygltf)

Relates : #152 #126

@syoyo syoyo added bug extension glTF extension labels Jul 23, 2019
@syoyo
Copy link
Owner

syoyo commented Jul 24, 2019

I have modified Material parser so that Material struct now has concrete parameter as defined in glTF 2.0 spec(also introduced TextureInfo struct) and can handle extensions

https://github.com/syoyo/tinygltf/tree/textureinfo

Thus no more opaque list of Parameter in Material(it still exists for backward compatibility, though).

struct Material {
  std::string name;

  std::vector<double> emissiveFactor;  // length 3. default [0, 0, 0]
  std::string alphaMode;               // default "OPAQUE"
  double alphaCutoff;                  // default 0.5
  bool doubleSided;                    // default false;

  PbrMetallicRoughness pbrMetallicRoughness;

  NormalTextureInfo normalTexture;
  OcclusionTextureInfo occlusionTexture;
  TextureInfo emissiveTexture;
  ...

loader_examples now show extensions in Material(or TextureInfo) correctly.

  pbrMetallicRoughness :
    baseColorFactor   : [ 1, 1, 1, 1 ]
    baseColorTexture  :
      index     : 0
      texCoord  : TEXCOORD_0

    metallicFactor    : 1
    roughnessFactor   : 1
    metallicRoughnessTexture  :
      index     : 1
      texCoord  : TEXCOORD_0
        KHR_texture_transform
            offset [ 
              0 , 
              1 
            ] 
            rotation : 1.5708
            scale [ 
              0.5 , 
              0.5 
            ] 

@UX3D-schmithuesen Could you please test textureinfo branch? Once things goes well on your side, I will merge textureinfo to master

@ghost
Copy link
Author

ghost commented Jul 25, 2019

Sounds great so far! I will test it with our project and come back to you in a few hours 👍

@ghost
Copy link
Author

ghost commented Jul 25, 2019

I opened a PR that fixes my only issue with this #182. It works much smoother for us now! 🎉

@syoyo
Copy link
Owner

syoyo commented Jul 25, 2019

Thanks! PR #182 has been merged, then textureinfo are merged into master.

So this issue should be ready to close.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug extension glTF extension
Projects
None yet
Development

No branches or pull requests

1 participant