-
I can not understand the effect of mask in this function, what is the benefit we can gain from this mask. "(mask & -(result >> (bytebits - 1)))" Could anyone explain it? Thank you very much. `static int quantizeColor(float v, int bytebits, int bits)
}` |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Imagine that we're using 16 bit colors to serialize in the glTF file. As per glTF spec, the only two fixed-point widths are 8 bit and 16 bit, and you have to store the value in 0..1 range, so you can't e.g. use 12 bits for storage. However, 16 bits is usually overkill from the precision perspective - as such, even for high quality color storage something like 12 bits is enough. It's possible to simply round the bit count to the next multiple of 8 (12 -> 16) and use that for storage. That's what In this example, when bits is 12 and bytebits is 16, we need to discard 4 lower bits. That's what It's tempting to just |
Beta Was this translation helpful? Give feedback.
-
I got it. Thank you for your explanation. |
Beta Was this translation helpful? Give feedback.
Imagine that we're using 16 bit colors to serialize in the glTF file. As per glTF spec, the only two fixed-point widths are 8 bit and 16 bit, and you have to store the value in 0..1 range, so you can't e.g. use 12 bits for storage. However, 16 bits is usually overkill from the precision perspective - as such, even for high quality color storage something like 12 bits is enough.
It's possible to simply round the bit count to the next multiple of 8 (12 -> 16) and use that for storage. That's what
meshopt_quantizeUnorm
does (when bits is 12, bytebits is 16). However, gltfpack tries to remove extra noise from the lower bits of the color by masking them out, which results in higher compression…