Vertex attributes added using emscripten path hard codes normalized flag to false
- Dominant language
- C++
- Stars
- 7.5k
- Forks
- 1.1k
- Avg merge
- 47m
- Merged PRs (30d)
- 1
Description
See https://github.com/KhronosGroup/glTF-Blender-IO/issues/2013 for some context.
It appears from [the code here](https://github.com/google/draco/blob/9f856abaafb4b39f1f013763ff061522e0261c6f/src/draco/point_cloud/point_cloud_builder.cc#L31-L32) that there is no way to add a vertex attribute that has the normalized flag set to true through the emscripten code path. This causes issues when trying to decode normalized vertex attributes since the decode APIs will return an attribute with normalized as false when it should be true.
```c++
int PointCloudBuilder::AddAttribute(GeometryAttribute::Type attribute_type,
int8_t num_components, DataType data_type) {
GeometryAttribute ga;
ga.Init(attribute_type, nullptr, num_components, data_type, false /* !!THIS IS HARDCODED!! */,
DataTypeLength(data_type) * num_components, 0);
return point_cloud_->AddAttribute(ga, true, point_cloud_->num_points());
}
```
To repro:
1. Download the `test.zip` from [this issue](https://github.com/BabylonJS/Babylon.js/issues/11685) and extract `no_draco_ushort_uvs.glb`.
2. Use [Don's glTF-Transform tool](https://gltf-transform.dev/) to encode Draco with the following command line:
```
gltf-transform draco no_draco_ushort_uvs.glb test.glb
```
3. Open test.glb with [the Babylon.js sandbox](https://sandbox.babylonjs.com/)
Result:
The console will output:
> Normalized flag from Draco data (false) does not match normalized flag from glTF accessor (true). Using flag from glTF accessor.
Expected:
The console does not show this warning.
Contributor guide
Assessment
This issue has not been assessed yet.