ngp_pl icon indicating copy to clipboard operation
ngp_pl copied to clipboard

Question for the occupancy grid code of Raymatching.cu

Open SCUTykLin opened this issue 1 year ago • 1 comments

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));

SCUTykLin avatar Oct 19 '23 13:10 SCUTykLin

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.

cwpeng-cn avatar Dec 21 '23 07:12 cwpeng-cn