-
Notifications
You must be signed in to change notification settings - Fork 252
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
Created accessor bufferViews should be byte aligned #421
Conversation
What is the error in Cesium? I took a look at Cesium_Air after going through gltf-pipeline and it seems like Cesium should still render it despite the validation errors. The model seems to meet this condition at least:
Though doesn't follow
Which is not good, but Cesium should still render it. The reason I bring this all up is because editing the byte offset is not enough, padding also needs to get added to the buffer which could be a longer fix. |
Getting the following WebGL errors:
The
|
lib/updateVersion.js
Outdated
@@ -804,7 +804,7 @@ function moveByteStrideToBufferView(gltf) { | |||
accessor.bufferView = newBufferViewId; | |||
accessor.byteOffset = accessor.byteOffset - currentByteOffset; | |||
} | |||
currentByteOffset = accessorByteOffset + accessorByteLength; | |||
currentByteOffset = accessorByteOffset + accessorByteLength + accessorByteLength % 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ggetz I stared at this for a really long time. The fix here is pretty close, but I think it needs to be
currentByteOffset = (i < accessorsLength - 1) ? accessors[i + 1].byteOffset : undefined;
Which is setting the current byte offset to next accessor's byte offset rather than the end of the current accessor. Cesium_Air brought up a discrepancy where these two values are not always the same if there is padding between the current accessor and the next accessor.
The % 4
approach works a lot of the time but has some edge cases (say if the current accessor ends at byte 1, next accessor starts at byte 1 too (both are using BYTE
component type), currentByteOffset
would be set to 2 and the next accessor's byte offset would be computed as -1.
This approach should work in Cesium without requiring the more involved changes of always aligning byte offsets and byte strides to 4 bytes, which I still think involves buffer copies of some sort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks @lilleyse! This means we don't have to pad the buffer correct? That's good news!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah no padding required for this fix thankfully.
Thanks again @lilleyse, updated. I can confirm Cesium Air now loads in CesiumGS/cesium#6805 with this change. |
Nice! |
Opened #426 so we can tackle the proper fix some other time. |
This is why
Cesium_Air.gltf
was not rendering in CesiumGS/cesium#6805The bufferViews created when splitting accessors with different byte strides must be byte aligned.