-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Sparse Array storage. #820
Comments
Please, confirm or correct me if I'm wrong. Unpacking such accessor into regular one would be like (roughly):
Then, we expect engine to use such array as an additional source of vertex attributes. |
Yes unpacking would work the way you described. Once unpacked the sparse accessor can be used as a regular one. |
@emilian0 thanks, this is a great start. May I suggest some tweaks: "mySparseAccessor": {
//---Initialization array, initializes the accessor with a syntax similar to a standard accessor---//
"bufferView":"bufferViewInitializationList",
"byteOffset":,
"byteStride":,
"count":,
//--sparse encoding of the values that changed with respect to the initialization array--//
"sparseCount": ,//<=number of "displaced" entries stored in the sparse array
"sparseValues": {
"bufferView": /* ... */,
"byteOffset": /* ... */,
"byteStride": /* ... */
},
"sparseIndices": {
"bufferView": /* ... */,
"byteOffset": /* ... */,
"byteStride": /* ... */
},
//---type and component type have the same semantic as in a standard accessor--//
"componentType": ,
"type": ""
}
And some questions:
|
One could think of sparse accessors as of "diffs" between regular accessors. The main expected use case is morph targets, because each morph target usually affects only specific mesh parts - not all vertices. @emilian0 |
@pjcozzi thank you for your suggestion above, sounds good to me. Actually why not placing all the new entries "sparseCount", "sparseValues", "sparseIndices". Into a "sparseStorage" entry?
note that sparse accessors will be listed, together with regular accessors, in the accessors top level dictionary. |
I agree with @lexaknyazev on that the only short term usage of sparse encoding in glTF is morph targets storage. |
@lexaknyazev, yes, you are right, we should specify sparseIndex data type. @lexaknyazev ,re: stride: I was considering the scenario of storing the sparse data as index-value pairs. Say that you are working with 32 bit indexes and values. Then you could specify stride =8 and, for instance, sparseValues offset = 0 and sparseIndices offset =4. Summary of offline conversation with @pjcozzi and @lexaknyazev : decision ->keep byteStride as an optional field. We don't expect it to be used often, but it brings value. |
@emilian0 thanks for the update; this all sounds good to me, just one small naming suggestion: "mySparseAccessor": {
...
"sparseStorage": {
"count":,
"values":{},
"indices": {},
}
} Since having Do you want to make the spec and schema updates? Also do you or anyone on your team have any bandwidth to add support for this to COLLADA2GLTF? On our team, @lasalvavida is updating COLLADA2GLTF to output glTF 2.0 (see this branch), but we do not have the bandwidth to add this feature right now. |
Thanks @pjcozzi , here the consolidated draft:
I am happy to take care of spec/schema updates. |
@emilian0 looks good, but did you address this question from @lexaknyazev:
If you added support to COLLADA2GLTF for converting COLLADA morph targets to glTF, it would be a home run. Each engine would then do their own implementation. @lasalvavida is working on the glTF 2.0 updates to COLLADA2GLTF and could advise on where to make the changes since he has done some refactoring with the 2.0 updates. |
@pjcozzi thanks for the comment, I have added a "componentType" to the "sparse/indices" dictionary. |
Naming it |
@pjcozzi , I took a look at the link you shared. Are you suggesting to have the sparse.indices (and sparse.values) fields point to an accessor ID as opposed to describing directly how to extract typed data from their bufferView? |
No, how you have it is OK. I was just trying to point out that when |
Opened a work-in-progress pull request on this issue (#833) |
@pjcozzi @lexaknyazev. Two quick questions before opening the pull request above for review/merge:
|
Fine with me.
OK, as long as mesh itself uses 32-bit indices. Also see #829. |
+1 to @lexaknyazev's comments. |
Updated in #826 |
Rationale
Sparse arrays are sometimes more efficient than dense arrays when describing incremental changes.
This scenario is common when encoding morph targets ( #210 ) that often display localized deformations (for instance, for a facial morph, a "blink-left" morph target will only displace vertices around the left eye). It is inefficient to re-transmit an entire full set of vertices positions when only a few of them were displaced. It is, in general, more efficient to just encode the indices and values of those vertices that were displaced in the morph target.
Following the COLLADA extension presented here, I suggest to include sparse array storage in the core glTF specs.
Possible implementation
glTF uses buffers to store data and accessors to retrieve it. I believe accessors are the structures to extend to accommodate for sparse storage. Here below a draft of what a sparse accessor might look like:
A sparse accessor has 3 components:
The text was updated successfully, but these errors were encountered: