-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
DracoLoader should normalise color data by default #26035
Comments
Are you loading .drc files, glTF files containing Draco compression data, or something else? All glTF files I see using Draco compression have used float32 vertex attributes, in which case normalization is not relevant. I don't know how to create Draco files containing uint8 or uint16 vertex colors, are you able to share examples? I agree that those could be marked as normalized. |
If possible, it would still be great to have an example of a .drc or .glb file with Draco compression, using normalized 8-bit or 16-bit attributes. |
I'm currently struggling with loading my I try to load the file using the following code: // Load a Draco geometry
loader.load(
// resource URL
'encoded_mesh.drc',
// called when the resource is loaded
function ( geometry ) {
const material = new THREE.MeshStandardMaterial( {vertexColors: true} );
const mesh = new THREE.Mesh( geometry, material );
mesh.geometry.attributes.color.normalized = true;
console.log(mesh.geometry.getAttribute("color"))
scene.add( mesh );
}, However the colors look very distorted (you can see a lot of clipping): This is no wonder when I look at the console output: Can I somehow tell Three.js that my colors are actually uInt8 values and not Float32? |
I'm not 100% sure on how Draco handles this, particularly with This type of issue should be handled automatically when using Draco data within a .gltf/.glb file, if that's an option for you. There's also this problem: Presumably your uint8 colors were normalized, and the Draco encoder would not have known that, I'm not sure what implications that might have here. If you can identify a solution, PRs on DRACOLoader would be welcome too! |
I'm not sure how the Draco encoder/decoder works on a low level, but I would expect that any uint8 RGBA values must be normalized. If they're not normalized, that might explain why our retrieving the value as float32 would return much larger values 2000+, as Draco wouldn't know how to decode the values as float32. |
Sorry for my noob question, but when you are talking about normalized uint8 values, you mean that they must be in the range of 0–255? Because that's definitely the case with my data. Or the other way around, how would a denormalized integer (uint8) look like? |
That's correct, but also — I think that Draco's encoder needs to be told that the data is normalized, so it knows they semantically represent 0–1 floats. In the WASM version of the Draco encoder it's not possible to do this correctly, this is the open issue in google/draco#1023, but if you're using the C++ encoder directly you might be able to just set the normalized flag when creating the Draco uint8 attribute, and then the Draco decoder may give the right results when three.js asks it to decode into a float32 array. |
Ahh, makes perfectly sense, thanks for the explanation. |
Description
I would expect color attributes from the loader to default to normalised
Solution
Set the
normalized
totrue
in the dracoLoaderAlternatives
This may be undesired behaviour for some users?
Additional context
https://github.com/NASA-AMMOS/3DTilesRendererJS/pull/326/files#r1182293106
The text was updated successfully, but these errors were encountered: