diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 89e50006..92a05325 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -92,6 +92,8 @@ From NeRF [[Mildenhall et al. 2020]](https://www.matthewtancik.com/nerf). Works The number of encoded dimensions is twice the specified number of frequencies for each input dimension. E.g. with `n_frequencies == 4`, an input dimension `x` becomes `sin(πx), cos(πx), sin(2πx), cos(2πx), sin(4πx), cos(4πx), sin(8πx), cos(8πx)`. +Note that many NeRF implementations (including the official ones) omit the factor of `π` from eq. (4) of the paper. This makes little difference in practice as coordinate normalization usually differs by similar amounts. Due to the logarithmic scaling of this encoding, this means that one or two fewer or additional frequency bands might be required to match results across implementations. + ```json5 { "otype": "Frequency", // Component type. diff --git a/include/tiny-cuda-nn/encodings/frequency.h b/include/tiny-cuda-nn/encodings/frequency.h index c041b652..27213fa5 100644 --- a/include/tiny-cuda-nn/encodings/frequency.h +++ b/include/tiny-cuda-nn/encodings/frequency.h @@ -71,9 +71,9 @@ __global__ void frequency_encoding( data_out(j, i) = 1; } else { /* Layout of encoded features (e.g. when inputs abcd.. are XYZ positions): - * sin(pi a.x), cos(pi a.x) sin(2pi a.x), cos(2pi a.x) sin(4pi a.x) ... - * sin(pi a.y), cos(pi a.y) sin(2pi a.y), cos(2pi a.y) sin(4pi a.y) ... - * sin(pi a.z), cos(pi a.z) sin(2pi a.z), cos(2pi a.z) sin(4pi a.z) ... + * sin(pi a.x), cos(pi a.x), sin(2pi a.x), cos(2pi a.x), sin(4pi a.x) ... + * sin(pi a.y), cos(pi a.y), sin(2pi a.y), cos(2pi a.y), sin(4pi a.y) ... + * sin(pi a.z), cos(pi a.z), sin(2pi a.z), cos(2pi a.z), sin(4pi a.z) ... * (padding) */ const uint32_t encoded_input_feature_i = j / (n_frequencies * 2);