zeux / meshoptimizer

Mesh optimization library that makes meshes smaller and faster to render
MIT License
5.49k stars 473 forks source link

gltfpack: Tangent quantization is capped at 8 bits #674

Closed Moichumoi closed 4 months ago

Moichumoi commented 5 months ago

When selecting 16 bit quantization for normals and tangents in the gltfpack.exe through the "-vn" argument, 8-bit quantization is used for the TANGENT attribute.

After quickly looking through the code, I noticed this line of code, which seems to be the culprit.

image

Is there a reason why normals can be 16-bit quantized but not tangents? The exe documentation (obtained through "-h") is a bit misleading at the moment, since you'd expect normals and tangents to be quantized with 16 bits if 16 is supplied as the argument.

zeux commented 5 months ago

I agree the help information is a bit misleading. This behavior is intentional and motivated by relative precision needs that are typical: 8-bit normals can result in visible specular quantization artifacts whereas tangents are typically less sensitive, so this allows something like -vn 12 to still produce a high quality output at a smaller incremental size cost.