- Home /
The question is answered, right answer was accepted
Texture mipmap distance
Hello,
Is it possible to define the texture mipmap generation distance ?
Thanks !
What is your intention and/or the problem you are having, why would you want to change it?
When i move the camera back the mipmap applied, but I want to increase the limit distance of mipmap application.
Yes, but why? If the mipmap is applied at greater distance, it means you would map a larger resolution texture to a smaller size, which will introduce more or less strong aliasing artifacts, and to prevent this type of artifacts is the exact reason mipmaps were invented for in the first place.
At this distance, the texture is too blury because of the mipmap
Answer by Wolfram · Aug 30, 2012 at 09:19 AM
The mipmap is visible whenever it is necessary. Modifying that distance wouldn't change anything, or would even introduce artifacts.
Texture is displayed closer/larger than 1:1 (=more than one pixel per texel): Mipmaps are not in use.
Texture is displayed farther away/smaller than 1:1 (=more than one texel per pixel): Mipmaps are in use, and the correct required mipmap level is automatically chosen, depending on the texel/pixel ratio. Note your interpolation will be incorrect unless you also set the filter mode to "Trilinear".
UPDATE: in a more recent Unity-Version (tested: 5.5) they added the parameter Texture.mipMapBias, which can override the value of which mipmap level will be accessed, and therefore does exactly what you want. In fact, as the default setting indeed resulty in overly blurry textures, Unity's computation might be incorrect, and a value like -0.5 might be the "correct" choice. Note the mipMapBias value can only be adjusted via script, is not persistent between Editor sessions, but IS persistent between different Play sessions in the Editor (=as long as the Editor is open).
Additionally @$$anonymous$$aT, toy with `Aniso Level` and `Filter $$anonymous$$ode` for better / more expensive results. Worked for me.
You're assu$$anonymous$$g the camera is looking straight at the texture. When looking at it from an angle, for example standing on the ground looking at the horizon, the ground texture will become very blurry because of mipmapping. Anisotrophic filtering can fix this (at a cost), but anisotrophic filtering isn't supported on all platforms. For mobile devices it would be usefull to be able to modify when it would switch mipmap levels (for textures that are only/primarily looked at at an angle).
Anisotropic filtering was created for precisely the situation you describe. No amount of regular mipmapping will help you there, it cannot improve the appearance of the far end of the texture beyond a certain level.
Please compare the 4 methods in the image below:
no mipmapping - which is essentially just a point filtering if the texels are smaller than a pixel.
mipmapping+bilinear - note the sharp edge in the distance where the chosen mipmap level is switched, resulting in a purely grey area (due to the worst-case texture "checkerboard")
mipmapping+trilinear - now the sharp edge is smoothed out, as now different mipmap levels are interpolated as well. However, at the far end, still 100% of the structure is lost
anisotropic filtering - only this method guarantees preserving the texture structure even at extreme angles. Note that even before the "bilinear edge" the texture is much sharper than with any mipmapping.
(open image in new tab and watch at 100%)
I know, read my comment again. I'm saying anisotropic filtering isn't supported on all platform, which makes it useless to me. And mipmapping without anisotropic looks worse than no mipmapping. Allowing to have it switch mipmaps farter, would reduce the blurriness, while still reducing the noisyness of non-mipmapping.
You would merely be able to adjust the amount of noise vs. blur, and as noise is extremely visible especially if the object or the camera are moving (which almost always is the case), it is highly likely that you couldn't move any mipmap switching much away from how it's currently behaving. If it's the blurring in the distance you want to reduce, you might also want to consider voting for this feature: http://feedback.unity3d.com/suggestions/maximum-mipmap-level