When I sample a texture in a pixel shader the texture unit needs to select a mipmap based on the texture gradient around the pixel being shaded.
There's a function tex2Dgrad()
which allows me to supply info about the gradient manually and tex2Dlod()
which allows me to select a mipmap manually but if I just call tex2D()
then where does the extra gradient information come from?
tex2D()
is the most common case for texture mapping, used in most shaders, but I have no idea where the gradient comes from. Mipmapping obviously works so it must come from somewhere.
I want to use a texture as a lookup table in a pixel shader using calculated U
and V
coordinates but I don't want any unexpected 'magic' happening in tex2D()
.
Do I need to use tex2Dlod()
to avoid this? I read that tex2Dlod()
is slower then tex2D()
.