sunset1995 / DirectVoxGO

Direct voxel grid optimization for fast radiance field reconstruction.
https://sunset1995.github.io/dvgo
Other
1.05k stars 110 forks source link

Question about the intervals in dmpigo #51

Open qihangGH opened 1 year ago

qihangGH commented 1 year ago

Hi @sunset1995, thanks for the great work!

I have a question about the intervals in dmpigo. When sampling the points on rays, as shown by a code fragment of the function sample_ndc_pts_on_rays_cuda_kernel in render_utils_kernel.cu,

const float dist = ((float)i_step) / (N_samples-1);
const float px = rays_o[offset_r  ] + rays_d[offset_r  ] * dist;
const float py = rays_o[offset_r+1] + rays_d[offset_r+1] * dist;
const float pz = rays_o[offset_r+2] + rays_d[offset_r+2] * dist;

the sample interval is 1 / (N_samples-1) times the length of the vector rays_d. The length of rays_d varies for different rays, so the sample interval is different among rays.

When rendering a ray, the interval is interval = render_kwargs['stepsize'] * self.voxel_size_ratio as defined in the forward method of the dmpigo class. It is a constant and so the interval in the rendering is the same for all rays.

I wonder why it is inconsistent in sampling and rendering. Great appreciate it if you can give some explanations.

sangminkim-99 commented 1 year ago

Hi, @qihangGH.

I think the inconsistency came from the original NeRF paper & implementation; so called 'Stratified Sampling'. The original volume rendering equation explains the integral of continuous functions.

image

But we don't have a continuous function but only neural radiance fields. So, we sample some discrete points to optimize the whole continuous scene. In this manner, we try to mimic the continuous integral by adding randomness to sample points.

From original NeRF paper: image

Thank you.