RenderOcc
RenderOcc copied to clipboard
关于render中的point sample
def sample_ray(ori_rays_o, ori_rays_d, step_size, scene_center, scene_radius, bg_len, world_len, bda, **render_kwargs):
rays_o = (ori_rays_o - scene_center) / scene_radius # normalization
rays_d = ori_rays_d / ori_rays_d.norm(dim=-1, keepdim=True)
N_inner = int(2 / (2+2*bg_len) * world_len / step_size) + 1
N_outer = N_inner//15 # hardcode: 15
b_inner = torch.linspace(0, 2, N_inner+1)
b_outer = 2 / torch.linspace(1, 1/64, N_outer+1)
t = torch.cat([
(b_inner[1:] + b_inner[:-1]) * 0.5,
(b_outer[1:] + b_outer[:-1]) * 0.5,
]).to(rays_o)
ray_pts = rays_o[:,None,:] + rays_d[:,None,:] * t[None,:,None]
norm = ray_pts.norm(dim=-1, keepdim=True)
inner_mask = (norm<=1)
ray_pts = torch.where(
inner_mask,
ray_pts,
ray_pts / norm * ((1+bg_len) - bg_len/norm)
)
按照代码的实现,会有大量采样点集中在scene的边界1m处,这样的理解正确吗。scene_radius取39,417个点中有285个采样点经过normalize后的norm是大于1的,这部分又会被后面的代码根据dist抑制掉,那么整体接近于均匀采样。