- Home /
Access current mip level at fragment shader
Is there a way to get, in the fragment shader, the current mip level of a texture? Any other value that is almost the same as the mip level is also valid
Answer by MakinStuffLookGood · Jun 25, 2018 at 06:03 PM
Check out this old blog post from Aras.
This is the technique still used in Unity today for visualizing how much you are under/over sampling mip-levels. Instead of using a texture whose mips are shades of blue and red with varying alpha, you could instead make your own mip-helper texture— with different greyscale values from black to white in it's mip levels. If you sample that texture with trilinear filtering, you'll have a smooth scalar value of the current mip level.
Note that Texture2D.SetPixels takes a mip-level as a parameter and could be useful for generating your mip-helper texture.
Your answer
![](https://koobas.hobune.stream/wayback/20220612162740im_/https://answers.unity.com/themes/thub/images/avi.jpg)