NVlabs / nvdiffrast

Nvdiffrast - Modular Primitives for High-Performance Differentiable Rendering

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to obtain per-pixel mipmap level

07hyx06 opened this issue · comments

Hi, thanks for the great project!

In my project I want to use the mipmap's level of each pixel to weight the photometric loss. I wonder is there a way to obtain the mipmap level for each pixel? I go through the document and find that the code to determine the mipmap level is inside the nvdiffrast.torch.texture function. Did I miss something?

Thanks in advance.

You're correct; the mipmap level calculation based on the texture coordinate pixel derivatives is an internal computation of the texturing op. Replicating the formula in pytorch would be simplest solution. A more hacky approach would be specifying a manual mipmap stack where the the texel values on each level contain the mip level number, run the texturing op, and read the result. This is probably not as efficient as running a replica of the formula, though, but could be used to validate the solution.

If you want to override the internally computed mipmap level in the texture op with one you have calculated yourself, you can do so via the mip_level_bias parameter.

Thanks!