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

Fix error in tutorial #25

Closed
wants to merge 1 commit into from

Conversation

math4origami
Copy link

I was trying to figure out how inverse bind pose works, and I was really confused until I realized there's an error here compared to the actual data in "Simple Skin".

Feel free to edit this change to be prettier, but I'd like to bring it up so it can be fixed. Perhaps it will require reediting the image as well.

I was trying to figure out how inverse bind pose works, and I was really confused until I realized there's an error here compared to the actual data in "Simple Skin".

Feel free to edit this change to be prettier, but I'd like to bring it up so it can be fixed.  Perhaps it will require reediting the image as well.
@javagl
Copy link
Contributor

javagl commented Feb 9, 2019

Thanks for this hint.

The creation of the tutorial, the Simple* models (originally in https://github.com/javagl/gltfTutorialModels/tree/2.0/SimpleSkin , no longer maintained), and the transition between glTF 1.0 and glTF 2.0 interfered a little, so it might be that an error slipped into the model.

Two remarks:

I'll add the SimpleSkin model ASAP, and cross-check with what is currently shown in the tutorial.

@math4origami
Copy link
Author

According to the data in "SimpleSkin", look at min and max in the "accessors" index 3, I see the -0.5:

"max" : [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -0.5, -1.0, 0.0, 1.0 ],
"min" : [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -0.5, -1.0, 0.0, 1.0 ]

The reason I found this is I was trying to follow along with the description in "Skins", and it said the mesh was "with the lower left point at the origin (0,0,0)", and a bunch of data with lots of x=0 coordinates.

But, then the diagram is completely different.
image

And then, subsequently, all following steps don't make sense to me for how "inverse bind pose" works.

@javagl
Copy link
Contributor

javagl commented Feb 10, 2019

Again, I'll have to analyze this more carefully. One of the changes between glTF 1.0 and 2.0 was that the "Bind Shape Matrix" was omitted, and assumed to be either premultiplied with the mesh data, or postmultiplied to the inverse bind matrices. This is likely where the -0.5 comes from (I just had a look at the 1.0 version of the SimpleSkin example at https://github.com/javagl/gltfTutorialModels/tree/master/SimpleSkin/glTF-Embedded-buffers , and it has different inverse bind matrices). In any case, I'll have to figure out how this can best be conveyed in the images.

@javagl
Copy link
Contributor

javagl commented Feb 10, 2019

OK, I figured this one out ... basically. It was indeed the Bind Shape Matrix that caused some confusion here. The simplest and most appropriate seems to be to update the tutorial, so that the example geometry is not in the x-range (0.0, 1.0) but (-0.5, 0.5).

However, some other (related) issue is now causing some headaches: I wanted to update the SimpleSkin example accordingly. But even though the following file passes validation, none of the viewers (except for my home-brewn one) manages to display the animation:

{
  "accessors" : [ {
    "bufferView" : 0,
    "byteOffset" : 0,
    "componentType" : 5123,
    "count" : 24,
    "type" : "SCALAR",
    "max" : [ 9 ],
    "min" : [ 0 ]
  }, {
    "bufferView" : 1,
    "byteOffset" : 0,
    "componentType" : 5126,
    "count" : 10,
    "type" : "VEC3",
    "max" : [ 0.5, 2.0, 0.0 ],
    "min" : [ -0.5, 0.0, 0.0 ]
  }, {
    "bufferView" : 2,
    "byteOffset" : 0,
    "componentType" : 5123,
    "count" : 10,
    "type" : "VEC4",
    "max" : [ 0, 1, 0, 0 ],
    "min" : [ 0, 1, 0, 0 ]
  }, {
    "bufferView" : 2,
    "byteOffset" : 160,
    "componentType" : 5126,
    "count" : 10,
    "type" : "VEC4",
    "max" : [ 1.0, 1.0, 0.0, 0.0 ],
    "min" : [ 0.0, 0.0, 0.0, 0.0 ]
  }, {
    "bufferView" : 3,
    "byteOffset" : 0,
    "componentType" : 5126,
    "count" : 2,
    "type" : "MAT4",
    "max" : [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.0, 1.0 ],
    "min" : [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, -1.0, 0.0, 1.0 ]
  }, {
    "bufferView" : 4,
    "byteOffset" : 0,
    "componentType" : 5126,
    "count" : 12,
    "type" : "SCALAR",
    "max" : [ 5.5 ],
    "min" : [ 0.0 ]
  }, {
    "bufferView" : 4,
    "byteOffset" : 48,
    "componentType" : 5126,
    "count" : 12,
    "type" : "VEC4",
    "max" : [ 0.0, 0.0, 0.707, 1.0 ],
    "min" : [ 0.0, 0.0, -0.707, 0.707 ]
  } ],
  "animations" : [ {
    "channels" : [ {
      "sampler" : 0,
      "target" : {
        "node" : 2,
        "path" : "rotation"
      }
    } ],
    "samplers" : [ {
      "input" : 5,
      "interpolation" : "LINEAR",
      "output" : 6
    } ]
  } ],
  "asset" : {
    "version" : "2.0"
  },
  "buffers" : [ {
    "uri" : "data:application/gltf-buffer;base64,AAABAAMAAAADAAIAAgADAAUAAgAFAAQABAAFAAcABAAHAAYABgAHAAkABgAJAAgAAAAAvwAAAAAAAAAAAAAAPwAAAAAAAAAAAAAAvwAAAD8AAAAAAAAAPwAAAD8AAAAAAAAAvwAAgD8AAAAAAAAAPwAAgD8AAAAAAAAAvwAAwD8AAAAAAAAAPwAAwD8AAAAAAAAAvwAAAEAAAAAAAAAAPwAAAEAAAAAA",
    "byteLength" : 168
  }, {
    "uri" : "data:application/gltf-buffer;base64,AAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAABAPwAAgD4AAAAAAAAAAAAAQD8AAIA+AAAAAAAAAAAAAAA/AAAAPwAAAAAAAAAAAAAAPwAAAD8AAAAAAAAAAAAAgD4AAEA/AAAAAAAAAAAAAIA+AABAPwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAA=",
    "byteLength" : 320
  }, {
    "uri" : "data:application/gltf-buffer;base64,AACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAgL8AAAAAAACAPwAAgD8AAAAAAAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIC/AAAAAAAAgD8=",
    "byteLength" : 128
  }, {
    "uri" : "data:application/gltf-buffer;base64,AAAAAAAAAD8AAIA/AADAPwAAAEAAACBAAABAQAAAYEAAAIBAAACQQAAAoEAAALBAAAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAkxjEPkSLbD8AAAAAAAAAAPT9ND/0/TQ/AAAAAAAAAAD0/TQ/9P00PwAAAAAAAAAAkxjEPkSLbD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAkxjEvkSLbD8AAAAAAAAAAPT9NL/0/TQ/AAAAAAAAAAD0/TS/9P00PwAAAAAAAAAAkxjEvkSLbD8AAAAAAAAAAAAAAAAAAIA/",
    "byteLength" : 240
  } ],
  "bufferViews" : [ {
    "buffer" : 0,
    "byteOffset" : 0,
    "byteLength" : 48,
    "target" : 34963
  }, {
    "buffer" : 0,
    "byteOffset" : 48,
    "byteLength" : 120,
    "target" : 34962
  }, {
    "buffer" : 1,
    "byteOffset" : 0,
    "byteLength" : 320,
    "byteStride" : 16
  }, {
    "buffer" : 2,
    "byteOffset" : 0,
    "byteLength" : 128
  }, {
    "buffer" : 3,
    "byteOffset" : 0,
    "byteLength" : 240
  } ],
  "meshes" : [ {
    "primitives" : [ {
      "attributes" : {
        "POSITION" : 1,
        "JOINTS_0" : 2,
        "WEIGHTS_0" : 3
      },
      "indices" : 0
    } ]
  } ],
  "nodes" : [ {
    "skin" : 0,
    "mesh" : 0
  }, {
    "children" : [ 2 ],
    "translation" : [ 0.0, 1.0, 0.0 ]
  }, {
    "rotation" : [ 0.0, 0.0, 0.0, 1.0 ]
  } ],
  "scenes" : [ {
    "nodes" : [ 0 ]
  } ],
  "skins" : [ {
    "inverseBindMatrices" : 4,
    "joints" : [ 1, 2 ]
  } ]
}

I'll have to sort this out as well...

@3dportable
Copy link

Hello, I'm trying to figure out how to display the GLTF file on Android OpenGLES20.
it is required to pass the parameter float [] [] to the shader
I tried it this way,
//joinMatrix
float[][] jointmatrix = new float[12][];
...
glUniformMatrix4fv(rs.u_jointMat, 1, false, jointmatrix, 0);
but the float [] [] array does not want to transmit.
please tell how to pass u_jointMat to shader glTF?

@javagl
Copy link
Contributor

javagl commented Feb 5, 2020

@3dportable This issue is about the glTF tutorial, and this is certainly not the right place to discuss specific Android implementation issues.

But I see...: Where else should you ask?

So for short: The array that is passed to glUniformMatrix4fv must be a 1D array. So if your jointMatrix array should be declared as

float[] jointMatrix = new float[numJoints * 12];

(You could convert your 2D float[][] array into a 1D float[] array immediately before calling glUniformMatrix4fv, but this could cause some memory/performance overhead that you may want to avoid...)

@javagl
Copy link
Contributor

javagl commented Feb 6, 2020

@3dportable I'm not familiar with Android and AndroidStudio in particular. I created JglTF, but was not able to invest much time there recently (and some parts of it would certainly need cleanups, refactorings, tests, and comments). Recently, someone made adaptions for Android and mentioned them in javagl/JglTF#4 (comment) , but I haven't yet found the time to take a closer look at this.

(A site note regarding Stack Overflow: A while ago, I would have tried to answer your question (and I've been among the top 0.5% contributors there), but I'm no longer active on the site, because ... all the things you can read on Meta StackExchange...)

@3dportable
Copy link

3dportable commented Feb 7, 2020 via email

@3dportable

This comment has been minimized.

@3dportable
Copy link

I want to be able to add mp3 track to each animation GLB.
How to do this?
Please tell about it in the documentation.

@javagl
Copy link
Contributor

javagl commented Mar 19, 2020

@3dportable glTF is intended for graphics. It is unrelated to sound, and specifically to MP3 files. You can add information in the extras, or define your own extension, though.

However, this repository is for the glTF tutorials, and this issue/PR is not a general place to ask random questions (so I'll stop responding to these). A better place for such random, open-end questions might be the forum at https://community.khronos.org/c/gltf-general/45

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@javagl
Copy link
Contributor

javagl commented Nov 19, 2021

This has been resolved by the update from #64

@javagl javagl closed this Nov 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants