ngp_pl
ngp_pl copied to clipboard
Question for the occupancy grid code of Raymatching.cu
I am a little confused about the implementation of occ, why we need to /8 when define the grid?
self.register_buffer('density_bitfield', torch.zeros(self.cascades*self.grid_size**3//8, dtype=torch.uint8))
And when we query the occ, also /8 and & (1 << (idx % 8)), Why?
const bool occ = density_bitfield[idx / 8] & (1 << (idx % 8));
I suspect that the reason is because the authors defined the density_bitfield using uint8, but since the values within density_bitfield only need to represent 0 or 1, a single element can represent the values for 8 positions. Therefore, when indexing, the expression const bool occ = density_bitfield[idx / 8] & (1 << (idx % 8)) is used to access the corresponding bit.