Skip to content

Commit

Permalink
FrequencyEncoding: add note about differing official NeRF implement…
Browse files Browse the repository at this point in the history
…ation in docs
  • Loading branch information
Tom94 committed Apr 19, 2023
1 parent 6f0cedb commit 922bb97
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 3 additions & 3 deletions include/tiny-cuda-nn/encodings/frequency.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 922bb97

Please sign in to comment.