bennyguo / instant-nsr-pl

Neural Surface reconstruction based on Instant-NGP. Efficient and customizable boilerplate for your research projects. Train NeuS in 10min!
MIT License
857 stars 84 forks source link

Why does estimated sdf use opposite sign in occ_eval_fn() and get_alpha() ? #14

Closed marlinilram closed 2 years ago

marlinilram commented 2 years ago

Hi, thanks for this great project!

I have a question about the estimate sdf in NeusModel. Why are the signs of prev/next opposite in occ_eval_fn() and get_alph() ?

https://github.com/bennyguo/instant-nsr-pl/blob/215274e2f99d2481ba00f3345fe3f3dd1b9c3d74/models/neus.py#L53

https://github.com/bennyguo/instant-nsr-pl/blob/215274e2f99d2481ba00f3345fe3f3dd1b9c3d74/models/neus.py#L81

bennyguo commented 2 years ago

Hi! Very good question! I should consider putting some comments in the code :)

In get_alpha, prev_cdf and next_cdf are calculated as follows:

estimated_next_sdf = sdf[...,None] + iter_cos * dists.reshape(-1, 1) * 0.5
estimated_prev_sdf = sdf[...,None] - iter_cos * dists.reshape(-1, 1) * 0.5

where iter_cos is a variable dependent on the ray direction, and ranges from -1 to 0.

In occ_eval_fn, we just want the approximate opacity value at some position (independent of the ray direction) for later pruning, so we simply compute the largest-possible alpha by taking iter_cos=-1, which yields:

estimated_next_sdf = sdf[...,None] - self.config.render_step_size * 0.5
estimated_prev_sdf = sdf[...,None] + self.config.render_step_size * 0.5
marlinilram commented 2 years ago

I see. Thanks for the quick reply!