Closed maorp closed 2 years ago
The screen-space derivatives (here diffs_attr
) should be consistent with the uv coordinates used for lookups -- otherwise mipmapping won't work as intended, and wrong mip levels may be used. Note that mipmapping is enabled only if the filter mode is either linear-mipmap-nearest
or linear-mipmap-linear
. In your code, you appear to have mipmapping turned off, so the contents of diffs_attr
don't actually affect the results at all.
If you want to use mipmapped texture lookups, you'll probably get a good approximation for the screen-space derivatives by dividing diffs_attr
by 2*W before the lookup, to account for the division and scale you do for the uv coordinates. It's not exactly correct, as W isn't constant in pixel space, but I doubt it's necessary to take that into account.
thanks for the awesome work. a question about nvdiffrast gradients, how should i handle the gradients when i do some operations between calling nvdiffrast functions, like in this 2 view texture projection code, here proj_coords created after interpolation and then W divided and normalized to [0,1] using torch, but then i call dr.texture and pass only the interpolation gradients to it. should I explicitly pass also torch grads to dr.texture?