bmild / nerf

Code release for NeRF (Neural Radiance Fields)
http://tancik.com/nerf
MIT License
9.58k stars 1.34k forks source link

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

Open shuochen365 opened 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.

oOXpycTOo commented 2 years ago

There is an explanatory diagram I've plotted. I'm not 100% sure it's a correct explanation, but this is how I understand it: image

city19992 commented 2 years ago

There is an explanatory diagram I've plotted. I'm not 100% sure it's a correct explanation, but this is how I understand it: image

I think it is correct.

kunkun0w0 commented 2 years ago

Hi,

I think the norm should multiply the ray_d before it adds with ray_o, which seems more reasonable.

Hugstar commented 1 year ago

dists are relative to the direction vector size. So for example, those 3 cases are exactly same for a given ray:

To normalize the dists to a unit-vector length, this normalization is performed

adaxun commented 1 year ago

I think we can refer to the sample point generation process to understand the principle . pts = rays_o[..., None, :] + rays_d[..., None, :] * z_vals[..., :, None] and the input of dists is sub by z_vals