draco icon indicating copy to clipboard operation
draco copied to clipboard

Vertex attributes added using emscripten path hard codes normalized flag to false

Open bghgary opened this issue 2 years ago • 1 comments

See https://github.com/KhronosGroup/glTF-Blender-IO/issues/2013 for some context.

It appears from the code here 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.

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 and extract no_draco_ushort_uvs.glb.
  2. Use Don's glTF-Transform tool 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

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.

bghgary avatar Sep 20 '23 21:09 bghgary

Support for normalized attributes in encoder emscripten will be added in the next release.

ondys avatar Oct 26 '23 17:10 ondys