In a piece of shading code I wish to know the mipmap level being sampled from a texture.
At my disposal I have a dPdx and dPdy. To determine the mipmap level I could sample from a texture with a unique colour at each mipmap level.
However, this would come at the cost of another texture sample and I’d like to know if a manual calculation would be possible and faster.
Is there any documentation on how rtTex2DGrad determines the final mipmap level sampled?
I’m working with OptiX 3.9.1 and CUDA 7.5.