/normal_encoding

Encoding float3 normal vectors to uint16 by using optimized sperical coords together with alias method.

Primary LanguageC++MIT LicenseMIT

Normal Vector Encoder/Decoder


  • Encoding float3 normal vectors to uint16 by using optimized spherical coords together with alias method, with a bounded error less than 0.562432 degree.

  • Both encoding and decoding are very fast. Encoding do use a search process to map jagged array entry to a linearized index, but the searching is short and cache friendly. (5 steps at most, <2 steps in average). Decoding don't do any searching at all.

  • Encoder need a 3172-bytes look up table, while decoder only needs 1362 bytes. (can be further reduced to 1/2 if exploit symmetries)

  • The code is not carefully optimized.