Skip to content
Discussion options

You must be logged in to vote

Well, it took a while :) I found the way to generate the origin and direction rays in the proper (nerf) way. I followed the procedure in the original nerf code

def get_rays_np(H, W, focal, c2w): #c2w = transform matrix
    """Get ray origins, directions from a pinhole camera."""
    i, j = np.meshgrid(np.arange(W, dtype=np.float32),
                       np.arange(H, dtype=np.float32), indexing='xy')
    dirs = np.stack([(i-W*.5)/focal, -(j-H*.5)/focal, -np.ones_like(i)], -1)
    rays_d = np.sum(dirs[..., np.newaxis, :] * c2w[:3, :3], -1)
    rays_o = np.broadcast_to(c2w[:3, -1], np.shape(rays_d))
    return rays_o, rays_d

As @JoanCharmant pointed out, make sure you use float32, not fl…

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
3 replies
@drperpen
Comment options

@JoanCharmant
Comment options

@drperpen
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by drperpen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants