Closed kamwoh closed 1 year ago
NDC depth (i.e., z/w) is returned as the third component of the rasterizer output. If you instead want linear camera-space depth or something else, you can compute that separately per-vertex and use it as a vertex attribute for interpolate
to get the depth map.
What do you mean by the occupancy of each face?
Thanks for helping. Can you please show an example of how to obtain the NDC depth? As I see only two elements are returned in this function:
For the occupancy, the soft rasterizer in pytorch3d will return the distance the signed Euclidean distance (in NDC units) in the x/y plane of each point closest to the pixel.
so I wonder if there are some similar functions in nvdiffrast?
Thanks!
The rasterization op returns two tensors; the first one is the main result tensor containing barycentrics, NDC depth, and triangle ID, and the second tensor contains screen-space derivatives of the barycentrics. The NDC depth is the third channel of the main result tensor. Thus, if you call rast, _ = nvdiffrast.torch.rasterize(...)
, the NDC depth is in rast[:, :, :, 2]
.
Note that gradients are not propagated from this NDC depth channel to vertex positions. If you need that, you must go the vertex attribute and nvdiffrast.torch.interpolate()
route.
Nvdiffrast does only point-sampled rasterization, so there is no concept of occupancy. There is a separate antialiasing op that approximates surface coverage across edges and adjusts pixel colors accordingly. This allows coverage-related gradients to propagate to vertex positions, and thus makes optimization of geometry possible.
Thanks for explanation
hi,
is there any way to obtain the occupancy of each face and the depth map after calling the
rasterize
function?the current rasterization seems like it only returns triangle IDs and the barycentrics