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] GltfExporter correctly exports buffer views for non-interleaved vertex data #4699

Merged
merged 6 commits into from
Oct 7, 2022

Conversation

mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Oct 6, 2022

  • Previously, a non-interleaved vertex buffer was stored using a single buffer view, which is not correct according to specs, as there is no single stride that can be specified for elements using it.
  • This stores a per element buffer view for non=interleaved vertex formats, and removes last validation errors.

Additionally, handling of unsupported textures is now handled without crashing (by ignoring them), for both gltf and usdz exporters.

@mvaligursky mvaligursky self-assigned this Oct 6, 2022
@mvaligursky mvaligursky marked this pull request as draft October 6, 2022 11:28
@kungfooman
Copy link
Collaborator

I am running into validation errors for a scene like this:

image

Errors:

image

I figured that instead of pushing a new accessor all the time, you can first check if a similiar one already exists - and use that id:

The code under vertexFormat.elements.forEach((element, elementIndex) => {, it can be done like:

                        const compareAccessor = (a, b) => {
                            return a.bufferView == b.bufferView &&
                              a.byteOffset == b.byteOffset &&
                              a.componentType == b.componentType &&
                              a.type == b.type &&
                              a.count == b.count;
                          }
                        let idx = json.accessors.findIndex(_ => compareAccessor(_, accessor))
                        if (idx === -1) {
                            idx = json.accessors.push(accessor) - 1;
                        }

That gets rid of the accessor errors, but I have no time to test more right more... accessor min/max should probably also be compared.

@mvaligursky
Copy link
Contributor Author

@kungfooman - thanks for the feedback, I fixed both issues.

@kungfooman
Copy link
Collaborator

Great work as always, I tested as far as I could and it works.

Only problem I have is the texture exporting code fails in SeeMore, because of a type issue. Instead of Texture#levels being some kind of image, it is actually a UInt8Array... and then it just crashes currently.

I wanted to fix it myself, but the size of the UInt8Array just doesn't make sense to me:

image

Apparently the texture size of that DDS is 1024x1024, but the length of the UInt8Array is 524.288. 1024*1024 is already 1.048.576🤔

@mvaligursky
Copy link
Contributor Author

Great work as always, I tested as far as I could and it works.

Thanks! Much appreciate your testing and feedback!

Only problem I have is the texture exporting code fails in SeeMore,

I added code to ignore those for now, just to avoid the crash. Can be properly handled in a separate PR there is more work on textures / materials to be done.

@mvaligursky mvaligursky marked this pull request as ready for review October 7, 2022 11:37
@mvaligursky mvaligursky merged commit 3b8e93a into main Oct 7, 2022
@mvaligursky mvaligursky deleted the mv-gltfexport-bufferviews branch October 7, 2022 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants