kwea123 / nerf_pl

NeRF (Neural Radiance Fields) and NeRF in the Wild using pytorch-lightning
https://www.youtube.com/playlist?list=PLDV2CyUo4q-K02pNEyDr7DYpTQuka3mbV
MIT License
2.74k stars 483 forks source link

NeRF:dists = dists * tf.linalg.norm(rays_d[..., None, :], axis=-1) #80

Closed shuochen365 closed 3 years ago

shuochen365 commented 3 years ago

Hi,

Why multiply each distance by the norm of the light in its corresponding direction to convert it into a real-world distance?

dists = dists * tf.linalg.norm(rays_d[..., None, :], axis=-1)

Can you explain the principle behind it?

Thanks.

kwea123 commented 3 years ago

In volume rendering theory, the opacity of a point is defined by its occupancy (sigma) and how long the light has traveled until that point (the distance). So in theory we need to multiply them together to compute alpha correctly. If you are asking for NDC however, I am not sure of the correct implementation, because in theory we need to convert everything back to euclidean space first, but in practice it seems that the we can simply use the distance in NDC, and whether multiplying by the distance or not doesn't matter (I don't in my implementation). In my understanding the sigma learnt in this way doesn't correspond to its physical meaning anymore, but kind of "pseudo-occupancy". I'm not sure how to explain this anyways.

shuochen365 commented 3 years ago

Thank you very much for your reply